From 2508084dc6e04afe40d2ba18d2891aae3156599f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Apr 2022 01:52:54 +0000 Subject: [PATCH 001/140] Auto-generated commit 2d73a9e5a6f7960b9fdd427e14138ceea6d2cf29 --- CONTRIBUTORS | 28 + LICENSE | 481 +++++++++ NOTICE | 1 + README.md | 282 ++++++ index.d.ts | 46 + index.mjs | 4 + index.mjs.map | 1 + package.json | 30 + stats.html | 2689 +++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 3562 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..b1b630a --- /dev/null +++ b/README.md @@ -0,0 +1,282 @@ + + +# Proxy + +[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] + +> [Proxy][mdn-proxy] object. + + + +
+ +
+ + + + + + + +
+ +## Usage + +```javascript +import Proxy from 'https://cdn.jsdelivr.net/gh/stdlib-js/proxy-ctor@esm/index.mjs'; +``` + +#### Proxy( target, handlers ) + +Returns a [proxy][mdn-proxy] object implementing custom behavior for specified object operations. + +```javascript +function get( target, property ) { + return target[ property ] * 2.0; +} + +var handlers = { + 'get': get +}; + +var p = new Proxy( {}, handlers ); + +p.a = 3.14; + +var v = p.a; +// returns 6.28 +``` + +A `handlers` argument should be an `object` whose properties are functions (called "**traps**") which define the behavior of the proxy when performing operations. The following traps are supported: + +- `getPrototypeOf( target )` + + - Trap for `Object.getPrototypeOf()`. Can be used to intercept the `instanceof` operator. The method must return an `object` or `null`. + +- `setPrototypeOf( target, prototype )` + + - Trap for `Object.setPrototypeOf()`. The method must return a `boolean` indicating if the prototype was successfully set. + +- `isExtensible( target )` + + - Trap for `Object.isExtensible()`. The method must return a `boolean`. + +- `preventExtensions( target )` + + - Trap for `Object.preventExtensions()`. The method must return a `boolean`. + +- `getOwnPropertyDescriptor( target, property )` + + - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an `object` or `undefined`. + +- `defineProperty( target, property, descriptor )` + + - Trap for `Object.defineProperty()`. The method must return a `boolean` indicating whether the operation succeeded. + +- `has( target, property )` + + - Trap for the `in` operator. The method must return a `boolean`. + +- `get( target, property, receiver )` + + - Trap for retrieving property values. The method can return any value. + +- `set( target, property, value, receiver )` + + - Trap for setting property values. The method should return a `boolean` indicating whether assignment succeeded. + +- `deleteProperty( target, property )` + + - Trap for the `delete` operator. The method must return a `boolean` indicating whether operation succeeded. + +- `ownKeys( target )` + + - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and `Object.getOwnPropertySymbols()`. The method must return an enumerable `object`. + +- `apply( target, thisArg, argumentsList )` + + - Trap for a function call. The method can return any value. + +- `construct( target, argumentsList, newTarget )` + + - Trap for the `new` operator. The method must return an `object`. + +All traps are **optional**. If a trap is not defined, the default behavior is to forward the operation to the target. + +
+ + + + + +
+ +
+ + + + + +
+ +## 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..4a76f0c --- /dev/null +++ b/index.d.ts @@ -0,0 +1,46 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2021 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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 + +// EXPORTS // + +/** +* Returns a proxied object. +* +* @param target - target object to wrap +* @param handlers - object whose properties are functions defining proxy behavior +* @returns proxied object +* +* @example +* function get( obj, prop ) { +* return obj[ prop ] * 2.0; +* } +* +* var handlers = { +* 'get': get +* }; +* +* var p = new Proxy( {}, handlers ); +* +* p.a = 3.14; +* +* var x = p.a; +* // returns 6.28 +*/ +export = Proxy; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..75a6d8e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy,e=function(r){return r},s=r()?t:e;export{s as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..047a9a1 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/polyfill.js","../lib/index.js","../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nmodule.exports = Proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* var Proxy = require( '@stdlib/proxy-ctor' );\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nvar hasProxySupport = require( '@stdlib/assert-has-proxy-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy;\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n"],"names":["builtin","Proxy","polyfill","target","lib","require$$0"],"mappings":";;4FAsDA,ICPIA,ECC2B,oBAAVC,MAA0B,KAAOA,MDAlDC,EDFJ,SAAgBC,GAEf,OAAOA,GCeRC,EAjBsBC,IASbL,EAEAE"} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..131eb3a --- /dev/null +++ b/package.json @@ -0,0 +1,30 @@ +{ + "name": "@stdlib/proxy-ctor", + "version": "0.0.0", + "description": "Proxy object.", + "license": "Apache-2.0", + "type": "module", + "main": "./index.mjs", + "homepage": "https://stdlib.io", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/proxy-ctor.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "keywords": [ + "stdlib", + "proxy", + "intercept", + "property", + "prop", + "access", + "object", + "obj" + ], + "funding": { + "type": "patreon", + "url": "https://www.patreon.com/athan" + } +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..40735d5 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + From a0e561f875d87e69ec251f08034edf2ed69d1818 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 30 Jun 2022 21:18:42 +0000 Subject: [PATCH 002/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 76e882c..21a8c94 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.x" + "@stdlib/assert-has-proxy-support": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-float64": "^0.0.x", @@ -78,4 +79,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 997f81115d21521dfa3fd41f11dd214377b8fac9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 08:16:27 +0000 Subject: [PATCH 003/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2740 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 4a76f0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 75a6d8e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy,e=function(r){return r},s=r()?t:e;export{s as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 047a9a1..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/polyfill.js","../lib/index.js","../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nmodule.exports = Proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* var Proxy = require( '@stdlib/proxy-ctor' );\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nvar hasProxySupport = require( '@stdlib/assert-has-proxy-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy;\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n"],"names":["builtin","Proxy","polyfill","target","lib","require$$0"],"mappings":";;4FAsDA,ICPIA,ECC2B,oBAAVC,MAA0B,KAAOA,MDAlDC,EDFJ,SAAgBC,GAEf,OAAOA,GCeRC,EAjBsBC,IASbL,EAEAE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 40735d5..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 4a28e8753c3bb827ccc9d6d2afe447f43bc81ce7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 08:17:19 +0000 Subject: [PATCH 004/140] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 681 ------ .github/workflows/publish.yml | 157 -- .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 35 +- benchmark/benchmark.js | 888 ------- branches.md | 53 - docs/repl.txt | 117 - docs/types/test.ts | 35 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 104 - test/test.polyfill.js | 70 - 39 files changed, 2711 insertions(+), 4419 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 53f6ee5..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-06-30T21:15:44.499Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2d3d012..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 128c22e..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,681 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the repository: - push: - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf - - git add -A - git commit -m "Remove files" - - git merge -s recursive -X theirs origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch or create new branch tag: - - name: 'Push changes to `deno` branch or create new branch tag' - run: | - SLUG=${{ github.repository }} - VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p') - if [ -z "$VERSION" ]; then - echo "Workflow job was not triggered by a new tag...." - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - else - echo "Workflow job was triggered by a new tag: $VERSION" - echo "Creating new bundle branch tag of the form $VERSION-deno" - git tag -a $VERSION-deno -m "$VERSION-deno" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-deno - fi - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf - - git add -A - git commit -m "Remove files" - - git merge -s recursive -X theirs origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -223,7 +216,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ce70d3a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index be73099..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/proxy/ctor" -click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 52d7ba6..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..92699b4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..07c1496 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy;\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor' ;\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support' ;\nimport builtin from './main.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8c4d9f7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index 21a8c94..6af4c62 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "proxyquire": "^2.0.0", - "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", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..b8d73fe --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From 501af3b5889cde78060f020e60abdb60dc76c5c1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 19:19:04 +0000 Subject: [PATCH 005/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 76e882c..21a8c94 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.x" + "@stdlib/assert-has-proxy-support": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-float64": "^0.0.x", @@ -78,4 +79,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From a1fa00a7b15b49883011bcabedad8361fdea7729 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 09:51:37 +0000 Subject: [PATCH 006/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2740 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 4a76f0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 92699b4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 07c1496..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy;\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor' ;\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support' ;\nimport builtin from './main.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b8d73fe..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From be360eb162c6b9125653118fe967eb23717a94bc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 09:52:31 +0000 Subject: [PATCH 007/140] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 681 ------ .github/workflows/publish.yml | 157 -- .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 35 +- benchmark/benchmark.js | 888 ------- branches.md | 53 - docs/repl.txt | 117 - docs/types/test.ts | 35 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 104 - test/test.polyfill.js | 70 - 39 files changed, 2711 insertions(+), 4419 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index ffe602c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-07-01T00:39:57.474Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2d3d012..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 128c22e..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,681 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the repository: - push: - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf - - git add -A - git commit -m "Remove files" - - git merge -s recursive -X theirs origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch or create new branch tag: - - name: 'Push changes to `deno` branch or create new branch tag' - run: | - SLUG=${{ github.repository }} - VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p') - if [ -z "$VERSION" ]; then - echo "Workflow job was not triggered by a new tag...." - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - else - echo "Workflow job was triggered by a new tag: $VERSION" - echo "Creating new bundle branch tag of the form $VERSION-deno" - git tag -a $VERSION-deno -m "$VERSION-deno" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-deno - fi - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf - - git add -A - git commit -m "Remove files" - - git merge -s recursive -X theirs origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -223,7 +216,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ce70d3a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index be73099..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/proxy/ctor" -click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 52d7ba6..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..92699b4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..07c1496 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy;\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor' ;\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support' ;\nimport builtin from './main.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8c4d9f7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index 21a8c94..6af4c62 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "proxyquire": "^2.0.0", - "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", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..e14c578 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From 0472b5ef8ed13f139a5df259d9e81b7a599a2fa8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 00:48:52 +0000 Subject: [PATCH 008/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 76e882c..21a8c94 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.x" + "@stdlib/assert-has-proxy-support": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-float64": "^0.0.x", @@ -78,4 +79,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From c41842aa576ab6daf06ced677716b628960eda47 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 13:30:58 +0000 Subject: [PATCH 009/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2740 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 4a76f0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 92699b4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 07c1496..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy;\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor' ;\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support' ;\nimport builtin from './main.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e14c578..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From bf8e0048f0726765490a0d2f71e53986ae9cf852 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 13:31:52 +0000 Subject: [PATCH 010/140] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 35 +- benchmark/benchmark.js | 888 ------- branches.md | 53 - docs/repl.txt | 117 - docs/types/test.ts | 35 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 104 - test/test.polyfill.js | 70 - 39 files changed, 2711 insertions(+), 4458 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 7eb77c7..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-08-01T00:43:25.119Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2d3d012..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -223,7 +216,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ce70d3a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index be73099..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/proxy/ctor" -click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 52d7ba6..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..92699b4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..07c1496 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy;\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor' ;\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support' ;\nimport builtin from './main.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8c4d9f7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index 21a8c94..6af4c62 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "proxyquire": "^2.0.0", - "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", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..e89ceef --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From 35df2c71f549c43701bbf2b1795c97a6a20d8440 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 03:13:55 +0000 Subject: [PATCH 011/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 76e882c..21a8c94 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.x" + "@stdlib/assert-has-proxy-support": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-float64": "^0.0.x", @@ -78,4 +79,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 3b4842b7ea05ea4aa040b4fa4e0b21fe00d78f1e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 16:05:27 +0000 Subject: [PATCH 012/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2740 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 4a76f0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 92699b4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 07c1496..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy;\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor' ;\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support' ;\nimport builtin from './main.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e89ceef..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From eb82ac9f25def1e2e8f35b09d7696d5bbb9af479 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 16:06:17 +0000 Subject: [PATCH 013/140] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 35 +- benchmark/benchmark.js | 888 ------- branches.md | 53 - docs/repl.txt | 117 - docs/types/test.ts | 35 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 104 - test/test.polyfill.js | 70 - 39 files changed, 2711 insertions(+), 4474 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 579dd03..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-09-01T00:38:42.778Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2d3d012..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -223,7 +216,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ce70d3a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index be73099..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/proxy/ctor" -click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 52d7ba6..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..92699b4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..07c1496 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy;\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor' ;\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support' ;\nimport builtin from './main.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8c4d9f7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index 21a8c94..6af4c62 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "proxyquire": "^2.0.0", - "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", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..1fc95e8 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From a3015f0b1b3907e544740ba3f5f4c7ee28b393de Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 03:32:42 +0000 Subject: [PATCH 014/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 76e882c..21a8c94 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.x" + "@stdlib/assert-has-proxy-support": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-float64": "^0.0.x", @@ -78,4 +79,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 3a2a9e7c2d91178e4f9402dae5755d1f4bb4ebe8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 13:02:20 +0000 Subject: [PATCH 015/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2740 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 4a76f0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 92699b4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 07c1496..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy;\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor' ;\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support' ;\nimport builtin from './main.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 1fc95e8..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From b5cf4eec6a71e17cb11cbb3581e9f73fef082b41 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 13:03:16 +0000 Subject: [PATCH 016/140] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 35 +- benchmark/benchmark.js | 888 ------- branches.md | 53 - docs/repl.txt | 117 - docs/types/test.ts | 35 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 104 - test/test.polyfill.js | 70 - 39 files changed, 2711 insertions(+), 4474 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 0e35866..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-10-01T01:02:42.631Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2d3d012..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -223,7 +216,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ce70d3a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index be73099..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/proxy/ctor" -click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 52d7ba6..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..92699b4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..07c1496 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy;\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor' ;\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support' ;\nimport builtin from './main.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8c4d9f7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index 21a8c94..6af4c62 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "proxyquire": "^2.0.0", - "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", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..8c945d2 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From 2b81d1ce7001e8a0db81b91f71438284d6aa7714 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 9 Oct 2022 02:03:58 +0000 Subject: [PATCH 017/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 76e882c..21a8c94 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.x" + "@stdlib/assert-has-proxy-support": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-float64": "^0.0.x", @@ -78,4 +79,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From a817f7b67373897f771ea68b32d2b831902d8261 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 9 Oct 2022 02:27:33 +0000 Subject: [PATCH 018/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2740 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 4a76f0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 92699b4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 07c1496..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy;\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor' ;\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support' ;\nimport builtin from './main.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8c945d2..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From eea496dd04460a35d16c2daaa218b86cea6a0fa4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 9 Oct 2022 02:28:19 +0000 Subject: [PATCH 019/140] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 35 +- benchmark/benchmark.js | 888 ------- branches.md | 53 - docs/repl.txt | 117 - docs/types/test.ts | 35 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 104 - test/test.polyfill.js | 70 - 38 files changed, 2711 insertions(+), 4473 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2d3d012..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -223,7 +216,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ce70d3a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index be73099..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/proxy/ctor" -click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 52d7ba6..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..92699b4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..4fa1123 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor' ;\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support' ;\nimport builtin from './main.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index 21a8c94..6af4c62 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "proxyquire": "^2.0.0", - "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", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..8d79f9c --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From 6c1162520c07dcf8fbe91a150da3fa9e30fe2039 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 04:36:13 +0000 Subject: [PATCH 020/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 76e882c..21a8c94 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.x" + "@stdlib/assert-has-proxy-support": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-float64": "^0.0.x", @@ -78,4 +79,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From f73757f72c150f2746343f6e21730b811dedd48d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 19:25:03 +0000 Subject: [PATCH 021/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2740 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 4a76f0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 92699b4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 4fa1123..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor' ;\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support' ;\nimport builtin from './main.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8d79f9c..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 76cecf7608a101eff4a188c3a5c3e35fa6bcd0a9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 19:25:49 +0000 Subject: [PATCH 022/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 35 +- benchmark/benchmark.js | 888 ----- branches.md | 53 - docs/repl.txt | 117 - docs/types/test.ts | 35 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 104 - test/test.polyfill.js | 70 - 39 files changed, 4066 insertions(+), 4474 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 58407b8..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-01T00:49:33.660Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 2d3d012..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 48996b9..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: '4 4 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9113bfe..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -223,7 +216,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ce70d3a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index be73099..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/proxy/ctor" -click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 52d7ba6..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..92699b4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..3f20285 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor' ;\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support' ;\nimport builtin from './main.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index 21a8c94..6af4c62 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "proxyquire": "^2.0.0", - "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", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..7e77015 --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From 5c5833651f21b14a653430488df85fd7f5c61e07 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 3 Nov 2022 23:28:13 +0000 Subject: [PATCH 023/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 76e882c..21a8c94 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.x" + "@stdlib/assert-has-proxy-support": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-float64": "^0.0.x", @@ -78,4 +79,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 39e1527560acb4cc1426a479e4034d006745d38e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 06:29:33 +0000 Subject: [PATCH 024/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4095 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 4a76f0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 92699b4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 3f20285..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor' ;\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support' ;\nimport builtin from './main.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7e77015..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 0851a490a4bda6231333b4f87b1f427ac7e143c3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 06:30:39 +0000 Subject: [PATCH 025/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 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 | 35 +- benchmark/benchmark.js | 888 ----- branches.md | 53 - docs/repl.txt | 117 - docs/types/test.ts | 35 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 104 - test/test.polyfill.js | 70 - 39 files changed, 4066 insertions(+), 4495 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 d0f4428..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-03T20:54:18.139Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 2d3d012..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 48996b9..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: '4 4 * * 4' - - # 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 + + ```
@@ -223,7 +216,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ce70d3a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index be73099..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/proxy/ctor" -click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 52d7ba6..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..92699b4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..3f20285 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor' ;\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support' ;\nimport builtin from './main.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index 21a8c94..6af4c62 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "proxyquire": "^2.0.0", - "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", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..2a31d1b --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From afcbd0534eeafe3c098d4f25c3d319cc914ef84d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 03:11:55 +0000 Subject: [PATCH 026/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2d1921c..ff2289a 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.x" + "@stdlib/assert-has-proxy-support": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-float64": "^0.0.x", @@ -78,4 +79,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From b9b7416a5b64fe6238417727a1e011c78f14e489 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 19:55:28 +0000 Subject: [PATCH 027/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4095 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 4a76f0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 92699b4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 3f20285..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor' ;\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support' ;\nimport builtin from './main.js' ;\nimport polyfill from './polyfill.js' ;\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2a31d1b..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From f63bba9ae9cd2390dd9e1b0d4d704f28396937fb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 19:56:33 +0000 Subject: [PATCH 028/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 781 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 183 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 35 +- benchmark/benchmark.js | 888 ----- branches.md | 53 - docs/repl.txt | 117 - docs/types/test.ts | 35 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 104 - test/test.polyfill.js | 70 - 39 files changed, 4066 insertions(+), 4500 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 51cb6e9..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-12-01T00:45:35.433Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 2d3d012..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 48996b9..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: '4 4 * * 4' - - # 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 + + ```
@@ -223,7 +216,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ce70d3a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index be73099..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/proxy/ctor" -click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 52d7ba6..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..92699b4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ac27950 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index ff2289a..6af4c62 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "proxyquire": "^2.0.0", - "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", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..f0f20eb --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From 0842e854a8e450a426094039b783c6834bc80913 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 02:44:54 +0000 Subject: [PATCH 029/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f1ad90a..d083cae 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.x" + "@stdlib/assert-has-proxy-support": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-float64": "^0.0.x", @@ -78,4 +79,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From ba82c4703e3d9f285cd53f81152d54366e10060e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 12:09:43 +0000 Subject: [PATCH 030/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4095 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 4a76f0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 92699b4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ac27950..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f0f20eb..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 4bbbe012dc0e436192aca80e9da7131278fa12fb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 12:10:43 +0000 Subject: [PATCH 031/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 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 | 35 +- benchmark/benchmark.js | 888 ----- branches.md | 53 - docs/repl.txt | 117 - docs/types/test.ts | 35 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 104 - test/test.polyfill.js | 70 - 39 files changed, 4066 insertions(+), 4511 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 d5a543a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-01-01T00:38:21.946Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 2d3d012..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 48996b9..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: '4 4 * * 4' - - # 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 + + ```
@@ -223,7 +216,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ce70d3a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index be73099..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/proxy/ctor" -click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 52d7ba6..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..ad85694 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ac27950 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index d083cae..6af4c62 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "proxyquire": "^2.0.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", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..17e92bc --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From d48dd6a52510e5072d38c6daa768e3389de8619d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 03:22:42 +0000 Subject: [PATCH 032/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f1ad90a..d083cae 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.x" + "@stdlib/assert-has-proxy-support": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-float64": "^0.0.x", @@ -78,4 +79,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 96176c2e7c3e67e7be9553140e3c2be81900c4e9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 14:02:16 +0000 Subject: [PATCH 033/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4095 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 4a76f0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ad85694..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ac27950..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 17e92bc..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 17512c322899016b713d0307109bf46c24b9f0e2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 14:03:04 +0000 Subject: [PATCH 034/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 791 --- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 184 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- benchmark/benchmark.js | 888 --- branches.md | 53 - docs/repl.txt | 117 - docs/types/test.ts | 35 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 104 - test/test.polyfill.js | 70 - 39 files changed, 6199 insertions(+), 4511 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 7909c1f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-02-01T00:44:01.332Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 2d3d012..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 48996b9..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: '4 4 * * 4' - - # 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 + + ```
@@ -223,7 +216,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ce70d3a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index be73099..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/proxy/ctor" -click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 52d7ba6..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..ad85694 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ac27950 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index d083cae..6af4c62 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "proxyquire": "^2.0.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", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..e8f0842 --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From 32ed64fd79c90632e210e90c40d6eba30af1189d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 01:18:17 +0000 Subject: [PATCH 035/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 1256f78..57db5ef 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.8" + "@stdlib/assert-has-proxy-support": "^0.0.8", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/array-float64": "^0.0.6", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From ab46f30030ecf2c50d89fd4db2a1753ef339fa90 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 03:05:56 +0000 Subject: [PATCH 036/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6228 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 4a76f0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ad85694..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ac27950..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e8f0842..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5e1d2596d76be15b468e62f05c6897f55a4c1686 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 03:06:41 +0000 Subject: [PATCH 037/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 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 | 35 +- benchmark/benchmark.js | 888 --- branches.md | 53 - docs/repl.txt | 117 - docs/types/test.ts | 35 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 104 - test/test.polyfill.js | 70 - 39 files changed, 6199 insertions(+), 4646 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 b27e888..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-03-01T00:57:17.166Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 2d3d012..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 48996b9..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: '4 4 * * 4' - - # 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 + + ```
@@ -223,7 +216,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ce70d3a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e9eb10..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 52d7ba6..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..ad85694 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ac27950 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index 57db5ef..4acb6b3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.6", - "@stdlib/bench": "^0.0.12", - "@stdlib/random-base-randu": "^0.0.8", - "proxyquire": "^2.0.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", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..c633e4a --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From 44b923fe78790b7ed02b403a9e0602e893265620 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 01:19:04 +0000 Subject: [PATCH 038/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 1256f78..57db5ef 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.8" + "@stdlib/assert-has-proxy-support": "^0.0.8", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/array-float64": "^0.0.6", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 9fe97b94ec59d185c1e37930b574355221bba333 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 02:53:32 +0000 Subject: [PATCH 039/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6228 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 4a76f0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ad85694..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ac27950..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c633e4a..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 847427bb6ed33dc08eaae1fc56291bf13f3b1b59 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 02:54:30 +0000 Subject: [PATCH 040/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 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 | 35 +- benchmark/benchmark.js | 888 --- branches.md | 53 - docs/repl.txt | 117 - docs/types/test.ts | 35 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 104 - test/test.polyfill.js | 70 - 39 files changed, 6199 insertions(+), 4652 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 7bd92f5..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-04-01T00:57:13.998Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 2d3d012..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 48996b9..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: '4 4 * * 4' - - # 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 + + ```
@@ -223,7 +216,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ce70d3a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e9eb10..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 52d7ba6..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..ad85694 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ac27950 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index 57db5ef..4acb6b3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.6", - "@stdlib/bench": "^0.0.12", - "@stdlib/random-base-randu": "^0.0.8", - "proxyquire": "^2.0.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", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..004de2a --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From 5d71645b3ced69689520026c1e7a8e1d486657b9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 01:17:41 +0000 Subject: [PATCH 041/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 1256f78..57db5ef 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.8" + "@stdlib/assert-has-proxy-support": "^0.0.8", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/array-float64": "^0.0.6", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 6bcd8fa016ae06800f086aa4e607142a5ed40404 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 02:49:27 +0000 Subject: [PATCH 042/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6228 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 4a76f0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ad85694..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ac27950..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 004de2a..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 21fb044b1bd2fe063b30766cdddb6948436d5e34 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 02:50:23 +0000 Subject: [PATCH 043/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- benchmark/benchmark.js | 888 --- branches.md | 53 - docs/repl.txt | 117 - docs/types/test.ts | 35 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 104 - test/test.polyfill.js | 70 - 39 files changed, 6199 insertions(+), 4652 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 07ff119..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-05-01T00:56:05.162Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 2d3d012..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 48996b9..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: '4 4 * * 4' - - # 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 + + ```
@@ -223,7 +216,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ce70d3a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e9eb10..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 52d7ba6..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..ad85694 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ac27950 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index 57db5ef..4acb6b3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.6", - "@stdlib/bench": "^0.0.12", - "@stdlib/random-base-randu": "^0.0.8", - "proxyquire": "^2.0.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", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..347f5b5 --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From e940809403909bfb32832938cfafef02cab06dd0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 01:22:25 +0000 Subject: [PATCH 044/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 1256f78..57db5ef 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.8" + "@stdlib/assert-has-proxy-support": "^0.0.8", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/array-float64": "^0.0.6", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 703c41bba32e4219f2d2356fa146f2a5f1578671 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 03:03:15 +0000 Subject: [PATCH 045/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6228 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 4a76f0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ad85694..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ac27950..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 347f5b5..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 9a56a3fd2aa00d74c2085e88155abafcdf4ee204 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 03:04:23 +0000 Subject: [PATCH 046/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- benchmark/benchmark.js | 888 --- branches.md | 53 - docs/repl.txt | 117 - docs/types/test.ts | 35 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 104 - test/test.polyfill.js | 70 - 39 files changed, 6199 insertions(+), 4652 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 17e4074..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-06-01T01:02:09.218Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 2d3d012..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 48996b9..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: '4 4 * * 4' - - # 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 + + ```
@@ -223,7 +216,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ce70d3a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e9eb10..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 52d7ba6..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..ad85694 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ac27950 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index 57db5ef..4acb6b3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.6", - "@stdlib/bench": "^0.0.12", - "@stdlib/random-base-randu": "^0.0.8", - "proxyquire": "^2.0.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", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..2cf1a1a --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From 0fc3caf0ae060526cdb2b1be59e377fff807cc2c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 01:22:15 +0000 Subject: [PATCH 047/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 1256f78..57db5ef 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.8" + "@stdlib/assert-has-proxy-support": "^0.0.8", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/array-float64": "^0.0.6", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From f93e74af731cd9367ce9ab0a88e33825d594a474 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 03:01:58 +0000 Subject: [PATCH 048/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6228 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 4a76f0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ad85694..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ac27950..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2cf1a1a..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 14ab7deac932706546c3553fe2ae7a5b1d0cce74 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 03:02:55 +0000 Subject: [PATCH 049/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- benchmark/benchmark.js | 888 --- branches.md | 53 - docs/repl.txt | 117 - docs/types/test.ts | 35 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 104 - test/test.polyfill.js | 70 - 39 files changed, 6199 insertions(+), 4652 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 bb96d94..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-07-01T01:01:35.307Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 2d3d012..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 48996b9..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: '4 4 * * 4' - - # 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 + + ```
@@ -223,7 +216,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ce70d3a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e9eb10..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 52d7ba6..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..ad85694 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ac27950 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index 57db5ef..4acb6b3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.6", - "@stdlib/bench": "^0.0.12", - "@stdlib/random-base-randu": "^0.0.8", - "proxyquire": "^2.0.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", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..c57981e --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From 18021bcea72d1bf3dcd74f02c4b9896b759a73e4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 01:23:04 +0000 Subject: [PATCH 050/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 1256f78..57db5ef 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.8" + "@stdlib/assert-has-proxy-support": "^0.0.8", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/array-float64": "^0.0.6", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 994ac9bb67e1144abb6b23cf33f6f60bc705d578 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 03:13:43 +0000 Subject: [PATCH 051/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6228 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 4a76f0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ad85694..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ac27950..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c57981e..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c75a9226fa64cb93f22c292d86722bd9773e65c0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 03:14:39 +0000 Subject: [PATCH 052/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- benchmark/benchmark.js | 888 --- branches.md | 53 - docs/repl.txt | 117 - docs/types/test.ts | 35 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 104 - test/test.polyfill.js | 70 - 39 files changed, 6199 insertions(+), 4652 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 8485805..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-08-01T00:59:03.964Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 2d3d012..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 48996b9..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: '4 4 * * 4' - - # 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 + + ```
@@ -223,7 +216,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ce70d3a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e9eb10..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 52d7ba6..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..ad85694 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ac27950 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index 57db5ef..4acb6b3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.6", - "@stdlib/bench": "^0.0.12", - "@stdlib/random-base-randu": "^0.0.8", - "proxyquire": "^2.0.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", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..7b3cbd0 --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From 7248ba6c1eff5c8b27fa89f2972be568ab797e92 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 20 Aug 2023 01:33:22 +0000 Subject: [PATCH 053/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 1256f78..57db5ef 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.8" + "@stdlib/assert-has-proxy-support": "^0.0.8", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/array-float64": "^0.0.6", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From e5f5c4144920a282cd5652b7a989e8daa1b7f596 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 20 Aug 2023 01:58:27 +0000 Subject: [PATCH 054/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6228 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 4a76f0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ad85694..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ac27950..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7b3cbd0..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 98d647a115d4630c165f458f4d1c250e6c75fac8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 20 Aug 2023 01:59:20 +0000 Subject: [PATCH 055/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 783 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- benchmark/benchmark.js | 888 --- branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 117 - docs/types/test.ts | 35 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 104 - test/test.polyfill.js | 70 - 41 files changed, 6199 insertions(+), 4653 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 2d3d012..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 48996b9..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: '4 4 * * 4' - - # 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 +216,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ce70d3a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e9eb10..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/proxy-ctor/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 b9a68ce..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Proxy from '../docs/types/index'; -export = Proxy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0f2b745..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var u=o(function(v,i){ -var x=typeof Proxy=="undefined"?null:Proxy;i.exports=x -});var p=o(function(c,s){ -function y(e){return e}s.exports=y -});var l=require('@stdlib/assert-has-proxy-support/dist'),n=u(),a=p(),t;l()?t=n:t=a;module.exports=t; -/** @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 959978d..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nmodule.exports = Proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* var Proxy = require( '@stdlib/proxy-ctor' );\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nvar hasProxySupport = require( '@stdlib/assert-has-proxy-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAgDA,IAAIC,EAAU,OAAO,OAAU,YAAgB,KAAO,MAKtDD,EAAO,QAAUC,ICrDjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8CA,SAASC,EAAOC,EAAS,CAExB,OAAOA,CACR,CAKAF,EAAO,QAAUC,ICRjB,IAAIE,EAAkB,QAAS,kCAAmC,EAC9DC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAgB,EACpBG,EAAQF,EAERE,EAAQD,EAMT,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "proxy", "require_polyfill", "__commonJSMin", "exports", "module", "Proxy", "target", "hasProxySupport", "builtin", "polyfill", "proxy"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 52d7ba6..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..ad85694 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ac27950 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index 57db5ef..4acb6b3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.6", - "@stdlib/bench": "^0.0.12", - "@stdlib/random-base-randu": "^0.0.8", - "proxyquire": "^2.0.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", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..d54281d --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From ea1330b0c7d275fbcac1caf03cdbe81b4f95506f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 04:25:23 +0000 Subject: [PATCH 056/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 58b5b86..7352854 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.1.0" + "@stdlib/assert-has-proxy-support": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0" }, "devDependencies": { "@stdlib/array-float64": "^0.0.6", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 58b7b9ab88d8508d879676ca7810808f23db79f7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 05:10:28 +0000 Subject: [PATCH 057/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6228 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 d24735b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ad85694..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ac27950..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d54281d..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 04398eacb5d03cc8b8dea4e1466ce89a915b0076 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 05:11:27 +0000 Subject: [PATCH 058/140] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 783 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- benchmark/benchmark.js | 888 --- branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 117 - docs/types/test.ts | 35 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 104 - test/test.polyfill.js | 70 - 42 files changed, 6199 insertions(+), 4688 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 2d3d012..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 48996b9..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: '4 4 * * 4' - - # 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 + + ```
@@ -234,7 +227,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ce70d3a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e9eb10..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/proxy-ctor/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 b9a68ce..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Proxy from '../docs/types/index'; -export = Proxy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0f2b745..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var u=o(function(v,i){ -var x=typeof Proxy=="undefined"?null:Proxy;i.exports=x -});var p=o(function(c,s){ -function y(e){return e}s.exports=y -});var l=require('@stdlib/assert-has-proxy-support/dist'),n=u(),a=p(),t;l()?t=n:t=a;module.exports=t; -/** @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 959978d..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nmodule.exports = Proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* var Proxy = require( '@stdlib/proxy-ctor' );\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nvar hasProxySupport = require( '@stdlib/assert-has-proxy-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAgDA,IAAIC,EAAU,OAAO,OAAU,YAAgB,KAAO,MAKtDD,EAAO,QAAUC,ICrDjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8CA,SAASC,EAAOC,EAAS,CAExB,OAAOA,CACR,CAKAF,EAAO,QAAUC,ICRjB,IAAIE,EAAkB,QAAS,kCAAmC,EAC9DC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAgB,EACpBG,EAAQF,EAERE,EAAQD,EAMT,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "proxy", "require_polyfill", "__commonJSMin", "exports", "module", "Proxy", "target", "hasProxySupport", "builtin", "polyfill", "proxy"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 52d7ba6..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..ad85694 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ac27950 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;4FAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index 7352854..cf5f7fc 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.0.6", - "@stdlib/bench": "^0.0.12", - "@stdlib/random-base-randu": "^0.0.8", - "proxyquire": "^2.0.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", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..afeca79 --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From 2525a740216ca2db7cc297e45802b932bd9160f6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 05:20:21 +0000 Subject: [PATCH 059/140] Update README.md for ESM bundle v0.1.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 97bfb25..060085f 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import Proxy from 'https://cdn.jsdelivr.net/gh/stdlib-js/proxy-ctor@esm/index.mjs'; +import Proxy from 'https://cdn.jsdelivr.net/gh/stdlib-js/proxy-ctor@v0.1.0-esm/index.mjs'; ``` #### Proxy( target, handlers ) @@ -159,7 +159,7 @@ All traps are **optional**. If a trap is not defined, the default behavior is to - - - - From d0da03e5e556c142de916594ea097ba223d3288e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Oct 2023 12:45:43 +0000 Subject: [PATCH 063/140] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 247 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- benchmark/benchmark.js | 888 --- branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 117 - docs/types/test.ts | 35 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 104 - test/test.js | 104 - test/test.polyfill.js | 70 - 44 files changed, 6199 insertions(+), 4851 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 bfaa0e0..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-10-01T00:54:37.574Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f4db4c6..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 5508eb2..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: '4 4 * * 4' - - # 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 + + ```
@@ -234,7 +227,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ce70d3a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e9eb10..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/proxy-ctor/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 b9a68ce..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Proxy from '../docs/types/index'; -export = Proxy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0f2b745..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var u=o(function(v,i){ -var x=typeof Proxy=="undefined"?null:Proxy;i.exports=x -});var p=o(function(c,s){ -function y(e){return e}s.exports=y -});var l=require('@stdlib/assert-has-proxy-support/dist'),n=u(),a=p(),t;l()?t=n:t=a;module.exports=t; -/** @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 959978d..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nmodule.exports = Proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* var Proxy = require( '@stdlib/proxy-ctor' );\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nvar hasProxySupport = require( '@stdlib/assert-has-proxy-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAgDA,IAAIC,EAAU,OAAO,OAAU,YAAgB,KAAO,MAKtDD,EAAO,QAAUC,ICrDjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8CA,SAASC,EAAOC,EAAS,CAExB,OAAOA,CACR,CAKAF,EAAO,QAAUC,ICRjB,IAAIE,EAAkB,QAAS,kCAAmC,EAC9DC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAgB,EACpBG,EAAQF,EAERE,EAAQD,EAMT,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "proxy", "require_polyfill", "__commonJSMin", "exports", "module", "Proxy", "target", "hasProxySupport", "builtin", "polyfill", "proxy"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 52d7ba6..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..75a6488 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.1.0-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..88b9dc2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index 3262a2d..cf5f7fc 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.0", - "proxyquire": "^2.0.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", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..e09188e --- /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 2350578..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../dist', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../dist', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From fb1dde75d3a87b428f08f612b8209e4a12b8c536 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 4 Oct 2023 00:30:29 +0000 Subject: [PATCH 064/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 5e421d9..d58936a 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.1.1" + "@stdlib/assert-has-proxy-support": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-float64": "^0.1.0", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From c7586d994c85cebb1a290caa1369aa3ff3b8947f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 4 Oct 2023 08:05:40 +0000 Subject: [PATCH 065/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6228 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 d24735b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 75a6488..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.1.0-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 88b9dc2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e09188e..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f583cf0953b9982fbd7e31643d5d44a88808b777 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 4 Oct 2023 08:09:20 +0000 Subject: [PATCH 066/140] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 247 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- benchmark/benchmark.js | 888 --- branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 117 - docs/types/test.ts | 35 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 104 - test/test.js | 104 - test/test.polyfill.js | 70 - 43 files changed, 6199 insertions(+), 4850 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f4db4c6..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 5508eb2..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: '4 4 * * 4' - - # 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 + + ```
@@ -234,7 +227,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ce70d3a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e9eb10..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/proxy-ctor/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 b9a68ce..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Proxy from '../docs/types/index'; -export = Proxy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0f2b745..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var u=o(function(v,i){ -var x=typeof Proxy=="undefined"?null:Proxy;i.exports=x -});var p=o(function(c,s){ -function y(e){return e}s.exports=y -});var l=require('@stdlib/assert-has-proxy-support/dist'),n=u(),a=p(),t;l()?t=n:t=a;module.exports=t; -/** @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 959978d..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nmodule.exports = Proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* var Proxy = require( '@stdlib/proxy-ctor' );\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nvar hasProxySupport = require( '@stdlib/assert-has-proxy-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAgDA,IAAIC,EAAU,OAAO,OAAU,YAAgB,KAAO,MAKtDD,EAAO,QAAUC,ICrDjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8CA,SAASC,EAAOC,EAAS,CAExB,OAAOA,CACR,CAKAF,EAAO,QAAUC,ICRjB,IAAIE,EAAkB,QAAS,kCAAmC,EAC9DC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAgB,EACpBG,EAAQF,EAERE,EAAQD,EAMT,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "proxy", "require_polyfill", "__commonJSMin", "exports", "module", "Proxy", "target", "hasProxySupport", "builtin", "polyfill", "proxy"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 52d7ba6..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..75a6488 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.1.0-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..88b9dc2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index d58936a..9060097 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.0", - "proxyquire": "^2.0.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", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..769743e --- /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 2350578..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../dist', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../dist', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From f86ebffbd583ea857403dc2af68bdc9c5407f388 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 4 Oct 2023 14:01:28 +0000 Subject: [PATCH 067/140] Update README.md for ESM bundle v0.1.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 88a023f..3acca7f 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import Proxy from 'https://cdn.jsdelivr.net/gh/stdlib-js/proxy-ctor@esm/index.mjs'; +import Proxy from 'https://cdn.jsdelivr.net/gh/stdlib-js/proxy-ctor@v0.1.1-esm/index.mjs'; ``` #### Proxy( target, handlers ) @@ -159,7 +159,7 @@ All traps are **optional**. If a trap is not defined, the default behavior is to - - - - From ff3ca748e8ac02b4b256e6f761e82bc3b70613cc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 13:37:49 +0000 Subject: [PATCH 071/140] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 247 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- benchmark/benchmark.js | 888 --- branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 117 - docs/types/test.ts | 35 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 104 - test/test.polyfill.js | 70 - 43 files changed, 6199 insertions(+), 4779 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f4db4c6..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 5508eb2..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: '4 4 * * 4' - - # 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 + + ```
@@ -234,7 +227,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ce70d3a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e9eb10..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/proxy-ctor/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 b9a68ce..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Proxy from '../docs/types/index'; -export = Proxy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0f2b745..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var u=o(function(v,i){ -var x=typeof Proxy=="undefined"?null:Proxy;i.exports=x -});var p=o(function(c,s){ -function y(e){return e}s.exports=y -});var l=require('@stdlib/assert-has-proxy-support/dist'),n=u(),a=p(),t;l()?t=n:t=a;module.exports=t; -/** @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 959978d..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nmodule.exports = Proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* var Proxy = require( '@stdlib/proxy-ctor' );\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nvar hasProxySupport = require( '@stdlib/assert-has-proxy-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAgDA,IAAIC,EAAU,OAAO,OAAU,YAAgB,KAAO,MAKtDD,EAAO,QAAUC,ICrDjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8CA,SAASC,EAAOC,EAAS,CAExB,OAAOA,CACR,CAKAF,EAAO,QAAUC,ICRjB,IAAIE,EAAkB,QAAS,kCAAmC,EAC9DC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAgB,EACpBG,EAAQF,EAERE,EAAQD,EAMT,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "proxy", "require_polyfill", "__commonJSMin", "exports", "module", "Proxy", "target", "hasProxySupport", "builtin", "polyfill", "proxy"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 52d7ba6..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..0788801 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.1.1-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..88b9dc2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index d58936a..9060097 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.0", - "proxyquire": "^2.0.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", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..c86c16c --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From 030a32db0313e3e0f03301f3b0a16abeb301bbfd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 01:31:18 +0000 Subject: [PATCH 072/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 117bf5f..e350421 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.1.1" + "@stdlib/assert-has-proxy-support": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-float64": "^0.1.1", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From df645ed37b03d9697a665065fe8d6162a6644824 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 09:40:03 +0000 Subject: [PATCH 073/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6228 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 d24735b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0788801..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.1.1-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 88b9dc2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c86c16c..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 64812f6ae5fbb3a2f143a51ffed39aea7dabcb1a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 09:43:25 +0000 Subject: [PATCH 074/140] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- benchmark/benchmark.js | 888 --- branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 117 - docs/types/test.ts | 35 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 104 - test/test.polyfill.js | 70 - 44 files changed, 6199 insertions(+), 4788 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 f8e083c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T00:54:03.687Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f4db4c6..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 5508eb2..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: '4 4 * * 4' - - # 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 + + ```
@@ -234,7 +227,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ce70d3a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e9eb10..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/proxy-ctor/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 b9a68ce..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Proxy from '../docs/types/index'; -export = Proxy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0f2b745..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var u=o(function(v,i){ -var x=typeof Proxy=="undefined"?null:Proxy;i.exports=x -});var p=o(function(c,s){ -function y(e){return e}s.exports=y -});var l=require('@stdlib/assert-has-proxy-support/dist'),n=u(),a=p(),t;l()?t=n:t=a;module.exports=t; -/** @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 959978d..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nmodule.exports = Proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* var Proxy = require( '@stdlib/proxy-ctor' );\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nvar hasProxySupport = require( '@stdlib/assert-has-proxy-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAgDA,IAAIC,EAAU,OAAO,OAAU,YAAgB,KAAO,MAKtDD,EAAO,QAAUC,ICrDjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8CA,SAASC,EAAOC,EAAS,CAExB,OAAOA,CACR,CAKAF,EAAO,QAAUC,ICRjB,IAAIE,EAAkB,QAAS,kCAAmC,EAC9DC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAgB,EACpBG,EAAQF,EAERE,EAAQD,EAMT,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "proxy", "require_polyfill", "__commonJSMin", "exports", "module", "Proxy", "target", "hasProxySupport", "builtin", "polyfill", "proxy"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 52d7ba6..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// tslint:disable: no-construct -// tslint:disable: no-unused-expression - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..0788801 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.1.1-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..88b9dc2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index e350421..9060097 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.1.1", - "@stdlib/bench": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.0", - "proxyquire": "^2.0.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", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..ba1f620 --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From de063eb9e2810ef620abddb7d31b8126478c5f78 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 12 Nov 2023 22:31:22 +0000 Subject: [PATCH 075/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f709fd4..16d9f39 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.1.1" + "@stdlib/assert-has-proxy-support": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-float64": "^0.1.1", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From c057bf53970b87183d24362d286fd20aaf8789ca Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 13 Nov 2023 00:23:05 +0000 Subject: [PATCH 076/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6228 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 d24735b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0788801..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.1.1-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 88b9dc2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ba1f620..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e02a12749955701c54550d052b8d374a16c19f28 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 13 Nov 2023 00:25:30 +0000 Subject: [PATCH 077/140] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- benchmark/benchmark.js | 888 --- branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 117 - docs/types/test.ts | 34 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 104 - test/test.polyfill.js | 70 - 43 files changed, 6199 insertions(+), 4786 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f4db4c6..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 5508eb2..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: '4 4 * * 4' - - # 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 + + ```
@@ -234,7 +227,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ce70d3a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e9eb10..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/proxy-ctor/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 b9a68ce..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Proxy from '../docs/types/index'; -export = Proxy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0f2b745..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var u=o(function(v,i){ -var x=typeof Proxy=="undefined"?null:Proxy;i.exports=x -});var p=o(function(c,s){ -function y(e){return e}s.exports=y -});var l=require('@stdlib/assert-has-proxy-support/dist'),n=u(),a=p(),t;l()?t=n:t=a;module.exports=t; -/** @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 959978d..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nmodule.exports = Proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* var Proxy = require( '@stdlib/proxy-ctor' );\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nvar hasProxySupport = require( '@stdlib/assert-has-proxy-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAgDA,IAAIC,EAAU,OAAO,OAAU,YAAgB,KAAO,MAKtDD,EAAO,QAAUC,ICrDjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8CA,SAASC,EAAOC,EAAS,CAExB,OAAOA,CACR,CAKAF,EAAO,QAAUC,ICRjB,IAAIE,EAAkB,QAAS,kCAAmC,EAC9DC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAgB,EACpBG,EAAQF,EAERE,EAAQD,EAMT,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "proxy", "require_polyfill", "__commonJSMin", "exports", "module", "Proxy", "target", "hasProxySupport", "builtin", "polyfill", "proxy"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b76b6da..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..0788801 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.1.1-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..88b9dc2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index 16d9f39..9060097 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.1.1", - "@stdlib/bench": "^0.2.0", - "@stdlib/random-base-randu": "^0.1.0", - "proxyquire": "^2.0.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", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..db6e1c7 --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From b239f478c2d4b8d4ec5095a72ca6f86ea7098a9c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 01:28:18 +0000 Subject: [PATCH 078/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 17a42d2..5f53c3f 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.1.1" + "@stdlib/assert-has-proxy-support": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-float64": "^0.1.1", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 640734c34efc28f20788ce5230cb1eec0ed6b47f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 06:20:27 +0000 Subject: [PATCH 079/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6228 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 d24735b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0788801..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.1.1-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 88b9dc2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index db6e1c7..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c9415f1a6256707f77865238052ae2095eb5d94a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 06:22:53 +0000 Subject: [PATCH 080/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- benchmark/benchmark.js | 888 --- branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 117 - docs/types/test.ts | 34 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 104 - test/test.polyfill.js | 70 - 44 files changed, 6199 insertions(+), 4782 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 cd6ac46..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T00:57:44.992Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f4db4c6..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 5508eb2..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: '4 4 * * 4' - - # 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 + + ```
@@ -234,7 +227,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ce70d3a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e9eb10..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/proxy-ctor/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 b9a68ce..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Proxy from '../docs/types/index'; -export = Proxy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0f2b745..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var u=o(function(v,i){ -var x=typeof Proxy=="undefined"?null:Proxy;i.exports=x -});var p=o(function(c,s){ -function y(e){return e}s.exports=y -});var l=require('@stdlib/assert-has-proxy-support/dist'),n=u(),a=p(),t;l()?t=n:t=a;module.exports=t; -/** @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 959978d..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nmodule.exports = Proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* var Proxy = require( '@stdlib/proxy-ctor' );\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nvar hasProxySupport = require( '@stdlib/assert-has-proxy-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAgDA,IAAIC,EAAU,OAAO,OAAU,YAAgB,KAAO,MAKtDD,EAAO,QAAUC,ICrDjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8CA,SAASC,EAAOC,EAAS,CAExB,OAAOA,CACR,CAKAF,EAAO,QAAUC,ICRjB,IAAIE,EAAkB,QAAS,kCAAmC,EAC9DC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAgB,EACpBG,EAAQF,EAERE,EAAQD,EAMT,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "proxy", "require_polyfill", "__commonJSMin", "exports", "module", "Proxy", "target", "hasProxySupport", "builtin", "polyfill", "proxy"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b76b6da..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..0788801 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.1.1-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..88b9dc2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index 5f53c3f..9060097 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.1.1", - "@stdlib/bench": "^0.2.1", - "@stdlib/random-base-randu": "^0.1.0", - "proxyquire": "^2.0.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", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..0751d99 --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From 6737077addb7b16b0ebb33492428cc9eead40070 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 01:21:26 +0000 Subject: [PATCH 081/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ae2fe20..3f3ab74 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.1.1" + "@stdlib/assert-has-proxy-support": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-float64": "^0.1.1", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 0d925049e21d1b6c87504fcb593c4feb8c47d09c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 03:38:38 +0000 Subject: [PATCH 082/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6228 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 d24735b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0788801..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.1.1-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 88b9dc2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0751d99..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ac696dcd66036778e7f19932e79578ec6d437ca0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 03:39:00 +0000 Subject: [PATCH 083/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- SECURITY.md | 5 - benchmark/benchmark.js | 888 --- branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 117 - docs/types/test.ts | 34 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 104 - test/test.polyfill.js | 70 - 45 files changed, 6199 insertions(+), 4788 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 4c32625..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T00:54:03.883Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f4db4c6..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 05f9937..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: '4 4 * * 4' - - # 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 + + ```
@@ -234,7 +227,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. 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 3812506..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7e9eb10..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/proxy-ctor/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 b9a68ce..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Proxy from '../docs/types/index'; -export = Proxy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0f2b745..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var u=o(function(v,i){ -var x=typeof Proxy=="undefined"?null:Proxy;i.exports=x -});var p=o(function(c,s){ -function y(e){return e}s.exports=y -});var l=require('@stdlib/assert-has-proxy-support/dist'),n=u(),a=p(),t;l()?t=n:t=a;module.exports=t; -/** @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 959978d..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nmodule.exports = Proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* var Proxy = require( '@stdlib/proxy-ctor' );\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nvar hasProxySupport = require( '@stdlib/assert-has-proxy-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAgDA,IAAIC,EAAU,OAAO,OAAU,YAAgB,KAAO,MAKtDD,EAAO,QAAUC,ICrDjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8CA,SAASC,EAAOC,EAAS,CAExB,OAAOA,CACR,CAKAF,EAAO,QAAUC,ICRjB,IAAIE,EAAkB,QAAS,kCAAmC,EAC9DC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAgB,EACpBG,EAAQF,EAERE,EAAQD,EAMT,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "proxy", "require_polyfill", "__commonJSMin", "exports", "module", "Proxy", "target", "hasProxySupport", "builtin", "polyfill", "proxy"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b76b6da..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..ab733bc --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.1.1-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..88b9dc2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index 3f3ab74..9060097 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.1.1", - "@stdlib/random-base-randu": "^0.1.0", - "proxyquire": "^2.0.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", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..f64711f --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From 2b76e580c322ca27953e426d37823562f964769e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 01:21:08 +0000 Subject: [PATCH 084/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ae2fe20..3f3ab74 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.1.1" + "@stdlib/assert-has-proxy-support": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-float64": "^0.1.1", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From c4b521a0be0d1d42fa80bc5e6ac8781ed0cf0cf3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 02:53:50 +0000 Subject: [PATCH 085/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6228 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 d24735b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ab733bc..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.1.1-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 88b9dc2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f64711f..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 8859db3ae0b938ac19624510eb7804f579f3366b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 02:54:13 +0000 Subject: [PATCH 086/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 888 --- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 117 - docs/types/test.ts | 34 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 104 - test/test.polyfill.js | 70 - 45 files changed, 6199 insertions(+), 4793 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 0548208..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-02-01T00:56:31.882Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f4db4c6..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 05f9937..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: '4 4 * * 4' - - # 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 + + ```
@@ -236,7 +227,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. 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 3812506..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f470363..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/proxy-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/proxy-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/proxy-ctor/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 b9a68ce..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Proxy from '../docs/types/index'; -export = Proxy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0f2b745..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var u=o(function(v,i){ -var x=typeof Proxy=="undefined"?null:Proxy;i.exports=x -});var p=o(function(c,s){ -function y(e){return e}s.exports=y -});var l=require('@stdlib/assert-has-proxy-support/dist'),n=u(),a=p(),t;l()?t=n:t=a;module.exports=t; -/** @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 959978d..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nmodule.exports = Proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* var Proxy = require( '@stdlib/proxy-ctor' );\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nvar hasProxySupport = require( '@stdlib/assert-has-proxy-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAgDA,IAAIC,EAAU,OAAO,OAAU,YAAgB,KAAO,MAKtDD,EAAO,QAAUC,ICrDjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8CA,SAASC,EAAOC,EAAS,CAExB,OAAOA,CACR,CAKAF,EAAO,QAAUC,ICRjB,IAAIE,EAAkB,QAAS,kCAAmC,EAC9DC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAgB,EACpBG,EAAQF,EAERE,EAAQD,EAMT,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "proxy", "require_polyfill", "__commonJSMin", "exports", "module", "Proxy", "target", "hasProxySupport", "builtin", "polyfill", "proxy"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b76b6da..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..ab733bc --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.1.1-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..88b9dc2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index 3f3ab74..9060097 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.1.1", - "@stdlib/random-base-randu": "^0.1.0", - "proxyquire": "^2.0.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", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..5dc5ea9 --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From d235e4167802f2599b5e902f85ad8106734ca0a0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 04:08:28 +0000 Subject: [PATCH 087/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7b715e8..a9f87c8 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.2.0" + "@stdlib/assert-has-proxy-support": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.2.0" }, "devDependencies": { "@stdlib/array-float64": "^0.1.1", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From ea0be97348158268687e6d8305718fb7fae15c3b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 05:10:31 +0000 Subject: [PATCH 088/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6228 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 d24735b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ab733bc..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.1.1-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 88b9dc2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5dc5ea9..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 937c83e57f67cb0de3341bb13e2314d164e084ef Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 05:10:58 +0000 Subject: [PATCH 089/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 888 --- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 117 - docs/types/test.ts | 34 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 104 - test/test.polyfill.js | 70 - 44 files changed, 6199 insertions(+), 4796 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f4db4c6..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d5b4be0..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: '4 4 * * 4' - - # 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 + + ```
@@ -236,7 +227,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. 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 3812506..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f470363..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/proxy-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/proxy-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/proxy-ctor/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 b9a68ce..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Proxy from '../docs/types/index'; -export = Proxy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0f2b745..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var u=o(function(v,i){ -var x=typeof Proxy=="undefined"?null:Proxy;i.exports=x -});var p=o(function(c,s){ -function y(e){return e}s.exports=y -});var l=require('@stdlib/assert-has-proxy-support/dist'),n=u(),a=p(),t;l()?t=n:t=a;module.exports=t; -/** @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 959978d..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nmodule.exports = Proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* var Proxy = require( '@stdlib/proxy-ctor' );\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nvar hasProxySupport = require( '@stdlib/assert-has-proxy-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAgDA,IAAIC,EAAU,OAAO,OAAU,YAAgB,KAAO,MAKtDD,EAAO,QAAUC,ICrDjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8CA,SAASC,EAAOC,EAAS,CAExB,OAAOA,CACR,CAKAF,EAAO,QAAUC,ICRjB,IAAIE,EAAkB,QAAS,kCAAmC,EAC9DC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAgB,EACpBG,EAAQF,EAERE,EAAQD,EAMT,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "proxy", "require_polyfill", "__commonJSMin", "exports", "module", "Proxy", "target", "hasProxySupport", "builtin", "polyfill", "proxy"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b76b6da..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..ab733bc --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.1.1-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..88b9dc2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index a9f87c8..f5bfa91 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.0", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.1.1", - "@stdlib/random-base-randu": "^0.1.0", - "proxyquire": "^2.0.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", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..7fa9ac9 --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From 1fc19040c465512bc4a6b483af0cb8aae3a482b8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 06:07:48 +0000 Subject: [PATCH 090/140] Update README.md for ESM bundle v0.2.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 586d8f0..db8c32d 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import Proxy from 'https://cdn.jsdelivr.net/gh/stdlib-js/proxy-ctor@esm/index.mjs'; +import Proxy from 'https://cdn.jsdelivr.net/gh/stdlib-js/proxy-ctor@v0.2.0-esm/index.mjs'; ``` #### Proxy( target, handlers ) @@ -159,7 +159,7 @@ All traps are **optional**. If a trap is not defined, the default behavior is to - - - - From 4f54f224fe0ff58f288deed8e466e3cb0bbca27b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 21 Feb 2024 22:54:30 +0000 Subject: [PATCH 094/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 888 ---- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 117 - docs/types/test.ts | 34 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 104 - test/test.polyfill.js | 70 - 44 files changed, 4864 insertions(+), 4790 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f4db4c6..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 89f1062..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: '4 4 * * 4' - - # 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 + + ```
@@ -236,7 +227,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. 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 3812506..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f470363..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/proxy-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/proxy-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/proxy-ctor/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 b9a68ce..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Proxy from '../docs/types/index'; -export = Proxy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0f2b745..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var u=o(function(v,i){ -var x=typeof Proxy=="undefined"?null:Proxy;i.exports=x -});var p=o(function(c,s){ -function y(e){return e}s.exports=y -});var l=require('@stdlib/assert-has-proxy-support/dist'),n=u(),a=p(),t;l()?t=n:t=a;module.exports=t; -/** @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 959978d..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nmodule.exports = Proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* var Proxy = require( '@stdlib/proxy-ctor' );\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nvar hasProxySupport = require( '@stdlib/assert-has-proxy-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAgDA,IAAIC,EAAU,OAAO,OAAU,YAAgB,KAAO,MAKtDD,EAAO,QAAUC,ICrDjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8CA,SAASC,EAAOC,EAAS,CAExB,OAAOA,CACR,CAKAF,EAAO,QAAUC,ICRjB,IAAIE,EAAkB,QAAS,kCAAmC,EAC9DC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAgB,EACpBG,EAAQF,EAERE,EAAQD,EAMT,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "proxy", "require_polyfill", "__commonJSMin", "exports", "module", "Proxy", "target", "hasProxySupport", "builtin", "polyfill", "proxy"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b76b6da..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..d357090 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.2.0-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..88b9dc2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index 468cbda..e658ce2 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.0", - "@stdlib/random-base-randu": "^0.2.0", - "proxyquire": "^2.0.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", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..19e38b9 --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From f9f4bbe2424989d795214592e95c9f008e2c7652 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 21 Feb 2024 23:07:03 +0000 Subject: [PATCH 095/140] Update README.md for ESM bundle v0.2.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 10552db..6e73e29 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import Proxy from 'https://cdn.jsdelivr.net/gh/stdlib-js/proxy-ctor@esm/index.mjs'; +import Proxy from 'https://cdn.jsdelivr.net/gh/stdlib-js/proxy-ctor@v0.2.1-esm/index.mjs'; ``` #### Proxy( target, handlers ) @@ -159,7 +159,7 @@ All traps are **optional**. If a trap is not defined, the default behavior is to - - - - From 4675ee4e96c12862fcc067b4c43b6327e8338859 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 01:57:15 +0000 Subject: [PATCH 099/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 888 ---- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 117 - docs/types/test.ts | 34 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 104 - test/test.polyfill.js | 70 - 45 files changed, 4864 insertions(+), 4792 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 8add980..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T00:57:59.860Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f4db4c6..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 89f1062..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: '4 4 * * 4' - - # 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 + + ```
@@ -236,7 +227,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. 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 3812506..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f470363..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/proxy-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/proxy-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/proxy-ctor/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 b9a68ce..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Proxy from '../docs/types/index'; -export = Proxy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0f2b745..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var u=o(function(v,i){ -var x=typeof Proxy=="undefined"?null:Proxy;i.exports=x -});var p=o(function(c,s){ -function y(e){return e}s.exports=y -});var l=require('@stdlib/assert-has-proxy-support/dist'),n=u(),a=p(),t;l()?t=n:t=a;module.exports=t; -/** @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 959978d..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nmodule.exports = Proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* var Proxy = require( '@stdlib/proxy-ctor' );\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nvar hasProxySupport = require( '@stdlib/assert-has-proxy-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAgDA,IAAIC,EAAU,OAAO,OAAU,YAAgB,KAAO,MAKtDD,EAAO,QAAUC,ICrDjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8CA,SAASC,EAAOC,EAAS,CAExB,OAAOA,CACR,CAKAF,EAAO,QAAUC,ICRjB,IAAIE,EAAkB,QAAS,kCAAmC,EAC9DC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAgB,EACpBG,EAAQF,EAERE,EAAQD,EAMT,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "proxy", "require_polyfill", "__commonJSMin", "exports", "module", "Proxy", "target", "hasProxySupport", "builtin", "polyfill", "proxy"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b76b6da..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..d1a6fb9 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.2.1-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..88b9dc2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index e5b8ebb..e658ce2 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.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.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..b48d894 --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From 009cb172c6dd1402efc87c1103b1fa34c5f74dda Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 01:06:22 +0000 Subject: [PATCH 100/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d228ef2..e5b8ebb 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.2.1" + "@stdlib/assert-has-proxy-support": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-float64": "^0.2.1", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 527b04fd0d50198a4166876723a0675e02416d84 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 02:15:29 +0000 Subject: [PATCH 101/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4893 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 d24735b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d1a6fb9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.2.1-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 88b9dc2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b48d894..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 6e16e00c7e7721c4ae8032442806c7883d0bfbf5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 02:15:42 +0000 Subject: [PATCH 102/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 888 ---- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 117 - docs/types/test.ts | 34 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 104 - test/test.polyfill.js | 70 - 45 files changed, 4864 insertions(+), 4795 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 4e48d75..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T00:51:38.953Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f4db4c6..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 89f1062..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: '4 4 * * 4' - - # 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 + + ```
@@ -236,7 +227,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. 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 3812506..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f470363..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/proxy-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/proxy-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/proxy-ctor/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 b9a68ce..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Proxy from '../docs/types/index'; -export = Proxy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0f2b745..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var u=o(function(v,i){ -var x=typeof Proxy=="undefined"?null:Proxy;i.exports=x -});var p=o(function(c,s){ -function y(e){return e}s.exports=y -});var l=require('@stdlib/assert-has-proxy-support/dist'),n=u(),a=p(),t;l()?t=n:t=a;module.exports=t; -/** @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 959978d..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nmodule.exports = Proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* var Proxy = require( '@stdlib/proxy-ctor' );\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nvar hasProxySupport = require( '@stdlib/assert-has-proxy-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAgDA,IAAIC,EAAU,OAAO,OAAU,YAAgB,KAAO,MAKtDD,EAAO,QAAUC,ICrDjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8CA,SAASC,EAAOC,EAAS,CAExB,OAAOA,CACR,CAKAF,EAAO,QAAUC,ICRjB,IAAIE,EAAkB,QAAS,kCAAmC,EAC9DC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAgB,EACpBG,EAAQF,EAERE,EAAQD,EAMT,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "proxy", "require_polyfill", "__commonJSMin", "exports", "module", "Proxy", "target", "hasProxySupport", "builtin", "polyfill", "proxy"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b76b6da..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..d1a6fb9 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.2.1-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..88b9dc2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index e5b8ebb..e658ce2 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.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.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..b48d894 --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From f9490dd749a0bb368ddb9786bd067323434ce7aa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 11 Apr 2024 21:13:37 +0000 Subject: [PATCH 103/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d228ef2..e5b8ebb 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.2.1" + "@stdlib/assert-has-proxy-support": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-float64": "^0.2.1", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 0aadf44ed5f84c97e2c4d8a8b95a6a08e1fc6975 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 11 Apr 2024 22:06:07 +0000 Subject: [PATCH 104/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4893 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 d24735b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d1a6fb9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.2.1-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 88b9dc2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b48d894..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From bedd00053badf1da14d91420dbe985eaafc5d83a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 11 Apr 2024 22:06:21 +0000 Subject: [PATCH 105/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 134 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 888 ---- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 117 - docs/types/test.ts | 34 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 104 - test/test.polyfill.js | 70 - 44 files changed, 4864 insertions(+), 4796 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f4db4c6..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 89f1062..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: '4 4 * * 4' - - # 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 + + ```
@@ -236,7 +227,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. 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 3812506..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f470363..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/proxy-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/proxy-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/proxy-ctor/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 b9a68ce..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Proxy from '../docs/types/index'; -export = Proxy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0f2b745..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var u=o(function(v,i){ -var x=typeof Proxy=="undefined"?null:Proxy;i.exports=x -});var p=o(function(c,s){ -function y(e){return e}s.exports=y -});var l=require('@stdlib/assert-has-proxy-support/dist'),n=u(),a=p(),t;l()?t=n:t=a;module.exports=t; -/** @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 959978d..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nmodule.exports = Proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* var Proxy = require( '@stdlib/proxy-ctor' );\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nvar hasProxySupport = require( '@stdlib/assert-has-proxy-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAgDA,IAAIC,EAAU,OAAO,OAAU,YAAgB,KAAO,MAKtDD,EAAO,QAAUC,ICrDjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8CA,SAASC,EAAOC,EAAS,CAExB,OAAOA,CACR,CAKAF,EAAO,QAAUC,ICRjB,IAAIE,EAAkB,QAAS,kCAAmC,EAC9DC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAgB,EACpBG,EAAQF,EAERE,EAAQD,EAMT,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "proxy", "require_polyfill", "__commonJSMin", "exports", "module", "Proxy", "target", "hasProxySupport", "builtin", "polyfill", "proxy"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b76b6da..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..d1a6fb9 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.2.1-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..88b9dc2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index e5b8ebb..e658ce2 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.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.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..b48d894 --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From 12549ba60b008836d087d84a87b0e7ed96ed4ea8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 May 2024 01:07:10 +0000 Subject: [PATCH 106/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d228ef2..e5b8ebb 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.2.1" + "@stdlib/assert-has-proxy-support": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-float64": "^0.2.1", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From b6f864b16965abe911b67e0de9890e339abffe52 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 May 2024 02:10:00 +0000 Subject: [PATCH 107/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4893 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 d24735b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d1a6fb9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.2.1-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 88b9dc2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b48d894..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 46a591efac5fbe734c992126022e2a89f08a4344 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 May 2024 02:10:21 +0000 Subject: [PATCH 108/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 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 | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 888 ---- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 117 - docs/types/test.ts | 34 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 104 - test/test.polyfill.js | 70 - 45 files changed, 4864 insertions(+), 4804 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 1558337..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-05-01T00:52:22.840Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f4db4c6..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 89f1062..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: '4 4 * * 4' - - # 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 + + ```
@@ -236,7 +227,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. 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 3812506..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f470363..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/proxy-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/proxy-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/proxy-ctor/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 b9a68ce..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Proxy from '../docs/types/index'; -export = Proxy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0f2b745..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var u=o(function(v,i){ -var x=typeof Proxy=="undefined"?null:Proxy;i.exports=x -});var p=o(function(c,s){ -function y(e){return e}s.exports=y -});var l=require('@stdlib/assert-has-proxy-support/dist'),n=u(),a=p(),t;l()?t=n:t=a;module.exports=t; -/** @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 959978d..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nmodule.exports = Proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* var Proxy = require( '@stdlib/proxy-ctor' );\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nvar hasProxySupport = require( '@stdlib/assert-has-proxy-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAgDA,IAAIC,EAAU,OAAO,OAAU,YAAgB,KAAO,MAKtDD,EAAO,QAAUC,ICrDjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8CA,SAASC,EAAOC,EAAS,CAExB,OAAOA,CACR,CAKAF,EAAO,QAAUC,ICRjB,IAAIE,EAAkB,QAAS,kCAAmC,EAC9DC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAgB,EACpBG,EAAQF,EAERE,EAAQD,EAMT,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "proxy", "require_polyfill", "__commonJSMin", "exports", "module", "Proxy", "target", "hasProxySupport", "builtin", "polyfill", "proxy"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b76b6da..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..d1a6fb9 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.2.1-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..88b9dc2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index e5b8ebb..e658ce2 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.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.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..b48d894 --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From 18b0c1e5f8e2185fbd9fda1582062b94b517eda0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jun 2024 01:10:24 +0000 Subject: [PATCH 109/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d228ef2..e5b8ebb 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.2.1" + "@stdlib/assert-has-proxy-support": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-float64": "^0.2.1", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 15c09e6c274955a97f925d233da95b5be7d519f3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jun 2024 02:05:12 +0000 Subject: [PATCH 110/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4893 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 d24735b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d1a6fb9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.2.1-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 88b9dc2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b48d894..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5648073eb61be8a13d0d2e3fa7153cc357aedffb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jun 2024 02:05:28 +0000 Subject: [PATCH 111/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 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 | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 888 ---- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 117 - docs/types/test.ts | 34 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 104 - test/test.polyfill.js | 70 - 45 files changed, 4864 insertions(+), 4804 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 927adda..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-06-01T00:57:48.873Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f4db4c6..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 89f1062..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: '4 4 * * 4' - - # 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 + + ```
@@ -236,7 +227,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. 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 3812506..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f470363..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/proxy-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/proxy-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/proxy-ctor/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 b9a68ce..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Proxy from '../docs/types/index'; -export = Proxy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0f2b745..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var u=o(function(v,i){ -var x=typeof Proxy=="undefined"?null:Proxy;i.exports=x -});var p=o(function(c,s){ -function y(e){return e}s.exports=y -});var l=require('@stdlib/assert-has-proxy-support/dist'),n=u(),a=p(),t;l()?t=n:t=a;module.exports=t; -/** @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 959978d..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nmodule.exports = Proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* var Proxy = require( '@stdlib/proxy-ctor' );\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nvar hasProxySupport = require( '@stdlib/assert-has-proxy-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAgDA,IAAIC,EAAU,OAAO,OAAU,YAAgB,KAAO,MAKtDD,EAAO,QAAUC,ICrDjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8CA,SAASC,EAAOC,EAAS,CAExB,OAAOA,CACR,CAKAF,EAAO,QAAUC,ICRjB,IAAIE,EAAkB,QAAS,kCAAmC,EAC9DC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAgB,EACpBG,EAAQF,EAERE,EAAQD,EAMT,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "proxy", "require_polyfill", "__commonJSMin", "exports", "module", "Proxy", "target", "hasProxySupport", "builtin", "polyfill", "proxy"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b76b6da..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..d1a6fb9 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.2.1-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..88b9dc2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index e5b8ebb..e658ce2 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.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.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..b48d894 --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From 16f6902387fd8b1940611a09cba0d3b96959cd80 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jul 2024 01:12:10 +0000 Subject: [PATCH 112/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d228ef2..e5b8ebb 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.2.1" + "@stdlib/assert-has-proxy-support": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-float64": "^0.2.1", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 1c260fe1c0991f0076ed3cf9c51f6cd7c1a70eb8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jul 2024 02:05:27 +0000 Subject: [PATCH 113/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4893 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 d24735b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d1a6fb9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.2.1-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 88b9dc2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b48d894..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5bb693b0157a0ea82154a12e42e83e854903ba2b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jul 2024 02:05:41 +0000 Subject: [PATCH 114/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 38 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 888 ---- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 117 - docs/types/test.ts | 34 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 104 - test/test.polyfill.js | 70 - 45 files changed, 4864 insertions(+), 4841 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 ecea68d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-07-01T00:58:20.513Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f4db4c6..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 89f1062..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: '4 4 * * 4' - - # 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 + + ```
@@ -236,7 +227,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. 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 3812506..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f470363..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/proxy-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/proxy-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/proxy-ctor/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 b9a68ce..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Proxy from '../docs/types/index'; -export = Proxy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0f2b745..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var u=o(function(v,i){ -var x=typeof Proxy=="undefined"?null:Proxy;i.exports=x -});var p=o(function(c,s){ -function y(e){return e}s.exports=y -});var l=require('@stdlib/assert-has-proxy-support/dist'),n=u(),a=p(),t;l()?t=n:t=a;module.exports=t; -/** @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 959978d..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nmodule.exports = Proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* var Proxy = require( '@stdlib/proxy-ctor' );\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nvar hasProxySupport = require( '@stdlib/assert-has-proxy-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAgDA,IAAIC,EAAU,OAAO,OAAU,YAAgB,KAAO,MAKtDD,EAAO,QAAUC,ICrDjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8CA,SAASC,EAAOC,EAAS,CAExB,OAAOA,CACR,CAKAF,EAAO,QAAUC,ICRjB,IAAIE,EAAkB,QAAS,kCAAmC,EAC9DC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAgB,EACpBG,EAAQF,EAERE,EAAQD,EAMT,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "proxy", "require_polyfill", "__commonJSMin", "exports", "module", "Proxy", "target", "hasProxySupport", "builtin", "polyfill", "proxy"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b76b6da..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..d1a6fb9 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.2.1-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..88b9dc2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index e5b8ebb..e658ce2 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.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.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..b48d894 --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From 81f91836953a0fdd6ecadfe4f9f4de4f7ea7031a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 00:24:25 +0000 Subject: [PATCH 115/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 64adbe0..4eb8a52 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.2.1" + "@stdlib/assert-has-proxy-support": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-float64": "^0.2.1", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From ec6fec22a3863e79c2cb633d9491f50153074e6a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 00:42:39 +0000 Subject: [PATCH 116/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4893 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 d24735b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d1a6fb9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.2.1-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 88b9dc2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b48d894..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c98804af2ea343e6d0f4a95c939819d3616e0b1b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 00:42:56 +0000 Subject: [PATCH 117/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 196 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 888 ---- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 117 - docs/types/test.ts | 34 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 104 - test/test.polyfill.js | 70 - 44 files changed, 4864 insertions(+), 4998 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f4db4c6..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 89f1062..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: '4 4 * * 4' - - # 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 + + ```
@@ -236,7 +227,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. 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 3812506..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f470363..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/proxy-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/proxy-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/proxy-ctor/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 b9a68ce..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Proxy from '../docs/types/index'; -export = Proxy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0f2b745..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var u=o(function(v,i){ -var x=typeof Proxy=="undefined"?null:Proxy;i.exports=x -});var p=o(function(c,s){ -function y(e){return e}s.exports=y -});var l=require('@stdlib/assert-has-proxy-support/dist'),n=u(),a=p(),t;l()?t=n:t=a;module.exports=t; -/** @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 959978d..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nmodule.exports = Proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* var Proxy = require( '@stdlib/proxy-ctor' );\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nvar hasProxySupport = require( '@stdlib/assert-has-proxy-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAgDA,IAAIC,EAAU,OAAO,OAAU,YAAgB,KAAO,MAKtDD,EAAO,QAAUC,ICrDjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8CA,SAASC,EAAOC,EAAS,CAExB,OAAOA,CACR,CAKAF,EAAO,QAAUC,ICRjB,IAAIE,EAAkB,QAAS,kCAAmC,EAC9DC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAgB,EACpBG,EAAQF,EAERE,EAAQD,EAMT,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "proxy", "require_polyfill", "__commonJSMin", "exports", "module", "Proxy", "target", "hasProxySupport", "builtin", "polyfill", "proxy"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b76b6da..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..d1a6fb9 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.2.1-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..88b9dc2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index 4eb8a52..a5b28a3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.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.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..b48d894 --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From 0c1c01415ca05e47616f3b0d5159abdfb65b672c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 00:55:12 +0000 Subject: [PATCH 118/140] Update README.md for ESM bundle v0.2.2 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 91ee34c..5d6d3d7 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import Proxy from 'https://cdn.jsdelivr.net/gh/stdlib-js/proxy-ctor@esm/index.mjs'; +import Proxy from 'https://cdn.jsdelivr.net/gh/stdlib-js/proxy-ctor@v0.2.2-esm/index.mjs'; ``` #### Proxy( target, handlers ) @@ -159,7 +159,7 @@ All traps are **optional**. If a trap is not defined, the default behavior is to - - - - From 66316d7c5fcc23b4439591cf5455d52faba3c470 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 02:05:44 +0000 Subject: [PATCH 122/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 158 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 888 ---- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 117 - docs/types/test.ts | 34 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 104 - test/test.polyfill.js | 70 - 45 files changed, 4864 insertions(+), 4963 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 b747eeb..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-01T00:59:56.520Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f4db4c6..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 89f1062..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: '4 4 * * 4' - - # 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 + + ```
@@ -236,7 +227,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. 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 3812506..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f470363..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/proxy-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/proxy-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/proxy-ctor/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 b9a68ce..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Proxy from '../docs/types/index'; -export = Proxy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0f2b745..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var u=o(function(v,i){ -var x=typeof Proxy=="undefined"?null:Proxy;i.exports=x -});var p=o(function(c,s){ -function y(e){return e}s.exports=y -});var l=require('@stdlib/assert-has-proxy-support/dist'),n=u(),a=p(),t;l()?t=n:t=a;module.exports=t; -/** @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 959978d..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nmodule.exports = Proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* var Proxy = require( '@stdlib/proxy-ctor' );\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nvar hasProxySupport = require( '@stdlib/assert-has-proxy-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAgDA,IAAIC,EAAU,OAAO,OAAU,YAAgB,KAAO,MAKtDD,EAAO,QAAUC,ICrDjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8CA,SAASC,EAAOC,EAAS,CAExB,OAAOA,CACR,CAKAF,EAAO,QAAUC,ICRjB,IAAIE,EAAkB,QAAS,kCAAmC,EAC9DC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAgB,EACpBG,EAAQF,EAERE,EAAQD,EAMT,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "proxy", "require_polyfill", "__commonJSMin", "exports", "module", "Proxy", "target", "hasProxySupport", "builtin", "polyfill", "proxy"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b76b6da..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..7aa10ac --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.2.2-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..88b9dc2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index d4f9a33..a5b28a3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..287961a --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From aa9cce531b2f498906fc71e07f077ed4b17d71b9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 15:50:25 +0000 Subject: [PATCH 123/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d143482..d4f9a33 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.2.2" + "@stdlib/assert-has-proxy-support": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-float64": "^0.2.2", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 79f3ca87afb1d3dfca7576ca27204baf4e0417a5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 16:23:28 +0000 Subject: [PATCH 124/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4893 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 d24735b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7aa10ac..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.2.2-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 88b9dc2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 287961a..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a1379e2ab968d0ccce56b4435f3187a6cc03c3f6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 16:23:45 +0000 Subject: [PATCH 125/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 196 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 888 ---- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 117 - docs/types/test.ts | 34 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 104 - test/test.polyfill.js | 70 - 45 files changed, 4864 insertions(+), 5001 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 fdc1558..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-03T15:40:46.328Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f4db4c6..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 89f1062..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: '4 4 * * 4' - - # 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 + + ```
@@ -236,7 +227,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. 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 3812506..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f470363..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/proxy-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/proxy-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/proxy-ctor/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 b9a68ce..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Proxy from '../docs/types/index'; -export = Proxy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0f2b745..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var u=o(function(v,i){ -var x=typeof Proxy=="undefined"?null:Proxy;i.exports=x -});var p=o(function(c,s){ -function y(e){return e}s.exports=y -});var l=require('@stdlib/assert-has-proxy-support/dist'),n=u(),a=p(),t;l()?t=n:t=a;module.exports=t; -/** @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 959978d..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nmodule.exports = Proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* var Proxy = require( '@stdlib/proxy-ctor' );\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nvar hasProxySupport = require( '@stdlib/assert-has-proxy-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAgDA,IAAIC,EAAU,OAAO,OAAU,YAAgB,KAAO,MAKtDD,EAAO,QAAUC,ICrDjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8CA,SAASC,EAAOC,EAAS,CAExB,OAAOA,CACR,CAKAF,EAAO,QAAUC,ICRjB,IAAIE,EAAkB,QAAS,kCAAmC,EAC9DC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAgB,EACpBG,EAAQF,EAERE,EAAQD,EAMT,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "proxy", "require_polyfill", "__commonJSMin", "exports", "module", "Proxy", "target", "hasProxySupport", "builtin", "polyfill", "proxy"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b76b6da..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..7aa10ac --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.2.2-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..88b9dc2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index d4f9a33..a5b28a3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..287961a --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From 866a9a256dea4fa0aeff47d06585413257687413 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 01:19:31 +0000 Subject: [PATCH 126/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d143482..d4f9a33 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.2.2" + "@stdlib/assert-has-proxy-support": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-float64": "^0.2.2", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 86920f0d63013b849b0d39bcb026826d31d41414 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 02:07:11 +0000 Subject: [PATCH 127/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4893 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 d24735b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7aa10ac..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.2.2-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 88b9dc2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 287961a..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f63e86620c15ff7e4a5f381e479ce8acff653939 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 02:07:26 +0000 Subject: [PATCH 128/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 195 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 888 ---- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 117 - docs/types/test.ts | 34 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 104 - test/test.polyfill.js | 70 - 45 files changed, 4864 insertions(+), 5000 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 a798e92..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-09-01T01:06:20.307Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f4db4c6..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 89f1062..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: '4 4 * * 4' - - # 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 + + ```
@@ -236,7 +227,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. 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 3812506..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f470363..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/proxy-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/proxy-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/proxy-ctor/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 b9a68ce..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Proxy from '../docs/types/index'; -export = Proxy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0f2b745..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var u=o(function(v,i){ -var x=typeof Proxy=="undefined"?null:Proxy;i.exports=x -});var p=o(function(c,s){ -function y(e){return e}s.exports=y -});var l=require('@stdlib/assert-has-proxy-support/dist'),n=u(),a=p(),t;l()?t=n:t=a;module.exports=t; -/** @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 959978d..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nmodule.exports = Proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* var Proxy = require( '@stdlib/proxy-ctor' );\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nvar hasProxySupport = require( '@stdlib/assert-has-proxy-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAgDA,IAAIC,EAAU,OAAO,OAAU,YAAgB,KAAO,MAKtDD,EAAO,QAAUC,ICrDjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8CA,SAASC,EAAOC,EAAS,CAExB,OAAOA,CACR,CAKAF,EAAO,QAAUC,ICRjB,IAAIE,EAAkB,QAAS,kCAAmC,EAC9DC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAgB,EACpBG,EAAQF,EAERE,EAAQD,EAMT,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "proxy", "require_polyfill", "__commonJSMin", "exports", "module", "Proxy", "target", "hasProxySupport", "builtin", "polyfill", "proxy"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b76b6da..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..7aa10ac --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.2.2-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..88b9dc2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index d4f9a33..a5b28a3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..287961a --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From 69245edb367bcdc22ce0fc3d4850cedefeaecfbe Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 01:24:02 +0000 Subject: [PATCH 129/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d143482..d4f9a33 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.2.2" + "@stdlib/assert-has-proxy-support": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-float64": "^0.2.2", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 0a3a28d7fb0408338697a2caf150411fb46433ba Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 02:11:10 +0000 Subject: [PATCH 130/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4893 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 d24735b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7aa10ac..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.2.2-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 88b9dc2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 287961a..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1d3da6f4adb20796c2d60ae2bec2178f212eeffe Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 02:11:26 +0000 Subject: [PATCH 131/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 195 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 888 ---- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 117 - docs/types/test.ts | 34 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 104 - test/test.polyfill.js | 70 - 45 files changed, 4864 insertions(+), 5000 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 bee65c5..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-10-01T01:11:45.391Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f4db4c6..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 89f1062..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: '4 4 * * 4' - - # 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 + + ```
@@ -236,7 +227,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. 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 3812506..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f470363..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/proxy-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/proxy-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/proxy-ctor/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 b9a68ce..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Proxy from '../docs/types/index'; -export = Proxy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0f2b745..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var u=o(function(v,i){ -var x=typeof Proxy=="undefined"?null:Proxy;i.exports=x -});var p=o(function(c,s){ -function y(e){return e}s.exports=y -});var l=require('@stdlib/assert-has-proxy-support/dist'),n=u(),a=p(),t;l()?t=n:t=a;module.exports=t; -/** @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 959978d..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nmodule.exports = Proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* var Proxy = require( '@stdlib/proxy-ctor' );\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nvar hasProxySupport = require( '@stdlib/assert-has-proxy-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAgDA,IAAIC,EAAU,OAAO,OAAU,YAAgB,KAAO,MAKtDD,EAAO,QAAUC,ICrDjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8CA,SAASC,EAAOC,EAAS,CAExB,OAAOA,CACR,CAKAF,EAAO,QAAUC,ICRjB,IAAIE,EAAkB,QAAS,kCAAmC,EAC9DC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAgB,EACpBG,EAAQF,EAERE,EAAQD,EAMT,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "proxy", "require_polyfill", "__commonJSMin", "exports", "module", "Proxy", "target", "hasProxySupport", "builtin", "polyfill", "proxy"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b76b6da..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..7aa10ac --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.2.2-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..88b9dc2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index d4f9a33..a5b28a3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..287961a --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From 7df1cfac10c8f19989e0667de234c463b81aa988 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 01:19:36 +0000 Subject: [PATCH 132/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d143482..d4f9a33 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.2.2" + "@stdlib/assert-has-proxy-support": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-float64": "^0.2.2", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 3fee84834e2b034d78f476fb922c1ca7f61846fc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 02:03:55 +0000 Subject: [PATCH 133/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4893 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 d24735b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7aa10ac..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.2.2-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 88b9dc2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 287961a..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 915b165c45f1f9ed8eff586ac5c5cdd3fd541053 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 02:04:07 +0000 Subject: [PATCH 134/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 195 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 888 ---- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 117 - docs/types/test.ts | 34 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 104 - test/test.polyfill.js | 70 - 45 files changed, 4864 insertions(+), 5000 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 a53b8b5..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-11-01T01:08:11.369Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f4db4c6..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 89f1062..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: '4 4 * * 4' - - # 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 + + ```
@@ -236,7 +227,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. 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 3812506..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f470363..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/proxy-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/proxy-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/proxy-ctor/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 b9a68ce..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Proxy from '../docs/types/index'; -export = Proxy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0f2b745..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var u=o(function(v,i){ -var x=typeof Proxy=="undefined"?null:Proxy;i.exports=x -});var p=o(function(c,s){ -function y(e){return e}s.exports=y -});var l=require('@stdlib/assert-has-proxy-support/dist'),n=u(),a=p(),t;l()?t=n:t=a;module.exports=t; -/** @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 959978d..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nmodule.exports = Proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* var Proxy = require( '@stdlib/proxy-ctor' );\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nvar hasProxySupport = require( '@stdlib/assert-has-proxy-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAgDA,IAAIC,EAAU,OAAO,OAAU,YAAgB,KAAO,MAKtDD,EAAO,QAAUC,ICrDjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8CA,SAASC,EAAOC,EAAS,CAExB,OAAOA,CACR,CAKAF,EAAO,QAAUC,ICRjB,IAAIE,EAAkB,QAAS,kCAAmC,EAC9DC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAgB,EACpBG,EAAQF,EAERE,EAAQD,EAMT,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "proxy", "require_polyfill", "__commonJSMin", "exports", "module", "Proxy", "target", "hasProxySupport", "builtin", "polyfill", "proxy"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b76b6da..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..7aa10ac --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.2.2-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..88b9dc2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index d4f9a33..a5b28a3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..287961a --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From 15824b91e0f379ff67774125eaf6273eeae90585 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 01:27:34 +0000 Subject: [PATCH 135/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d143482..d4f9a33 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.2.2" + "@stdlib/assert-has-proxy-support": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-float64": "^0.2.2", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From c3714e5c3c251ce80dc7e895e879f8e4249207b7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 02:09:53 +0000 Subject: [PATCH 136/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4893 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 d24735b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7aa10ac..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.2.2-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 88b9dc2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 287961a..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d74ce57ed6e486367c730280ff6cdc2067146130 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 02:10:13 +0000 Subject: [PATCH 137/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 195 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 888 ---- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 117 - docs/types/test.ts | 34 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 104 - test/test.polyfill.js | 70 - 46 files changed, 4864 insertions(+), 5105 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.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 6517923..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-01T01:14:18.055Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index bc9753a..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f4db4c6..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 89f1062..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: '4 4 * * 4' - - # 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 + + ```
@@ -236,7 +227,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. 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 3812506..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f470363..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/proxy-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/proxy-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/proxy-ctor/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 b9a68ce..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Proxy from '../docs/types/index'; -export = Proxy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0f2b745..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var u=o(function(v,i){ -var x=typeof Proxy=="undefined"?null:Proxy;i.exports=x -});var p=o(function(c,s){ -function y(e){return e}s.exports=y -});var l=require('@stdlib/assert-has-proxy-support/dist'),n=u(),a=p(),t;l()?t=n:t=a;module.exports=t; -/** @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 959978d..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nmodule.exports = Proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* var Proxy = require( '@stdlib/proxy-ctor' );\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nvar hasProxySupport = require( '@stdlib/assert-has-proxy-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAgDA,IAAIC,EAAU,OAAO,OAAU,YAAgB,KAAO,MAKtDD,EAAO,QAAUC,ICrDjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8CA,SAASC,EAAOC,EAAS,CAExB,OAAOA,CACR,CAKAF,EAAO,QAAUC,ICRjB,IAAIE,EAAkB,QAAS,kCAAmC,EAC9DC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAgB,EACpBG,EAAQF,EAERE,EAAQD,EAMT,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "proxy", "require_polyfill", "__commonJSMin", "exports", "module", "Proxy", "target", "hasProxySupport", "builtin", "polyfill", "proxy"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b76b6da..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..7aa10ac --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.2.2-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..88b9dc2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index d4f9a33..a5b28a3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..287961a --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests From 164ab8f715c72560702c1981b1b8936a15415c54 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 14 Apr 2025 01:07:43 +0000 Subject: [PATCH 138/140] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d143482..d4f9a33 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.2.2" + "@stdlib/assert-has-proxy-support": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-float64": "^0.2.2", @@ -78,4 +79,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From a4824dae670f61784db73ca3561f842c4c684d7a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 14 Apr 2025 01:36:09 +0000 Subject: [PATCH 139/140] Remove files --- index.d.ts | 46 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4893 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 d24735b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Returns a proxied object. -* -* @param target - target object to wrap -* @param handlers - object whose properties are functions defining proxy behavior -* @returns proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -export = Proxy; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7aa10ac..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.2.2-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 88b9dc2..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 287961a..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 887295166e8fd154ee5384ce5111db0525bf2660 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 14 Apr 2025 01:36:27 +0000 Subject: [PATCH 140/140] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 195 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 888 ---- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 117 - docs/types/test.ts | 34 - examples/index.js | 54 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 54 - lib/polyfill.js | 55 - package.json | 58 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 104 - test/test.polyfill.js | 70 - 46 files changed, 4864 insertions(+), 5108 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.polyfill.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 58bb431..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-04-14T01:06:34.527Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 55ed8a5..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/proxy/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index f4db4c6..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/proxy/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 89f1062..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: '4 4 * * 4' - - # 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 + + ```
@@ -236,7 +227,7 @@ for ( i = 0; i < p.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. 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 3812506..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,888 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var Proxy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var handlers; - var p; - var i; - - handlers = { - 'get': get - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - p = new Proxy( {}, handlers ); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof p !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::typed_array,proxy,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': get - }; - - arr = new Float64Array( 10 ); - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( obj, prop ) { - return obj[ prop ]; - } -}); - -bench( pkg+'::array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,get', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,getter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.get = get; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = []; - arr.get = get; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,getter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'get': handler - }; - - arr = new Float64Array( 10 ); - arr.get = get; - - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr.get( 0 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop ) { - return obj[ prop ]; - } - - function get( i ) { - return this[ i ]; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - arr = new Proxy( arr, handlers ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::typed_array,proxy,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': set - }; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( obj, prop, value ) { - obj[ prop ] = value; - return true; - } -}); - -bench( pkg+'::array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,proxy,no_handlers,set', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,no_proxy,set', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = randu(); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,no_proxy,setter', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,no_handlers,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = {}; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = []; - arr.set = set; - - for ( i = 0; i < 10; i++ ) { - arr.push( 0.0 ); - } - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); - -bench( pkg+'::typed_array,proxy,setter', function benchmark( b ) { - var handlers; - var arr; - var N; - var v; - var i; - - handlers = { - 'set': handler - }; - - arr = new Float64Array( 10 ); - arr.set = set; - N = arr.length; - - arr = new Proxy( arr, handlers ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.set( i%N, randu() ); - v = arr[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function handler( obj, prop, value ) { - obj[ prop ] = value; - return true; - } - - function set( i, v ) { - this[ i ] = v; // eslint-disable-line no-invalid-this - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f470363..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/proxy/ctor" -%% click B href "https://github.com/stdlib-js/proxy-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/proxy-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/proxy-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/proxy-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/proxy-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/proxy/ctor -[production-url]: https://github.com/stdlib-js/proxy-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/proxy-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/proxy-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/proxy-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/proxy-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/proxy-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/proxy-ctor/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 b9a68ce..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import Proxy from '../docs/types/index'; -export = Proxy; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0f2b745..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var o=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var u=o(function(v,i){ -var x=typeof Proxy=="undefined"?null:Proxy;i.exports=x -});var p=o(function(c,s){ -function y(e){return e}s.exports=y -});var l=require('@stdlib/assert-has-proxy-support/dist'),n=u(),a=p(),t;l()?t=n:t=a;module.exports=t; -/** @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 959978d..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/polyfill.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nmodule.exports = Proxy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* var Proxy = require( '@stdlib/proxy-ctor' );\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nvar hasProxySupport = require( '@stdlib/assert-has-proxy-support' );\nvar builtin = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = proxy;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAgDA,IAAIC,EAAU,OAAO,OAAU,YAAgB,KAAO,MAKtDD,EAAO,QAAUC,ICrDjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA8CA,SAASC,EAAOC,EAAS,CAExB,OAAOA,CACR,CAKAF,EAAO,QAAUC,ICRjB,IAAIE,EAAkB,QAAS,kCAAmC,EAC9DC,EAAU,IACVC,EAAW,IAKXC,EACCH,EAAgB,EACpBG,EAAQF,EAERE,EAAQD,EAMT,OAAO,QAAUC", - "names": ["require_main", "__commonJSMin", "exports", "module", "proxy", "require_polyfill", "__commonJSMin", "exports", "module", "Proxy", "target", "hasProxySupport", "builtin", "polyfill", "proxy"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4633e19..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,117 +0,0 @@ - -{{alias}}( target, handlers ) - Returns a proxy object implementing custom behavior for specified object - operations. - - The following "traps" are supported: - - - getPrototypeOf( target ) - Trap for `Object.getPrototypeOf()`. Can be used to intercept the - `instanceof` operator. The method must return an object or `null`. - - - setPrototypeOf( target, prototype ) - Trap for `Object.setPrototypeOf()`. The method must return a boolean - indicating if prototype successfully set. - - - isExtensible( target ) - Trap for `Object.isExtensible()`. The method must return a boolean. - - - preventExtensions( target ) - Trap for `Object.preventExtensions()`. The method must return a boolean. - - - getOwnPropertyDescriptor( target, property ) - Trap for `Object.getOwnPropertyDescriptor()`. The method must return an - object or `undefined`. - - - defineProperty( target, property, descriptor ) - Trap for `Object.defineProperty()`. The method must return a boolean - indicating whether the operation succeeded. - - - has( target, property ) - Trap for the `in` operator. The method must return a boolean. - - - get( target, property, receiver ) - Trap for retrieving property values. The method can return any value. - - - set( target, property, value, receiver ) - Trap for setting property values. The method should return a boolean - indicating whether assignment succeeded. - - - deleteProperty( target, property ) - Trap for the `delete` operator. The method must return a boolean - indicating whether operation succeeded. - - - ownKeys( target ) - Trap for `Object.keys`, `Object.getOwnPropertyNames()`, and - `Object.getOwnPropertySymbols()`. The method must return an enumerable - object. - - - apply( target, thisArg, argumentsList ) - Trap for a function call. The method can return any value. - - - construct( target, argumentsList, newTarget ) - Trap for the `new` operator. The method must return an object. - - All traps are optional. If a trap is not defined, the default behavior is to - forward the operation to the target. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Proxy object. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = new {{alias}}( {}, h ); - > p.a = 3.14; - > p.a - 6.28 - - -{{alias}}.revocable( target, handlers ) - Returns a revocable proxy object. - - Parameters - ---------- - target: Object - Object which the proxy virtualizes. - - handlers: Object - Object whose properties are functions which define the behavior of the - proxy when performing operations. - - Returns - ------- - p: Object - Revocable proxy object. - - p.proxy: Object - Proxy object. - - p.revoke: Function - Invalidates a proxy, rendering a proxy object unusable. - - Examples - -------- - > function get( obj, prop ) { return obj[ prop ] * 2.0 }; - > var h = { 'get': get }; - > var p = {{alias}}.revocable( {}, h ); - > p.proxy.a = 3.14; - > p.proxy.a - 6.28 - > p.revoke(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b76b6da..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Proxy = require( './index' ); - - -// TESTS // - -// The function returns a proxied object. -{ - new Proxy( {}, {} ); // $ExpectType {} -} - -// The constructor function has to be invoked with `new`... -{ - Proxy( {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a2a94ab..0000000 --- a/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var Proxy = require( './../lib' ); - -var handlers; -var arr; -var p; -var i; - -// Create a new typed array: -arr = new Float64Array( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; -} - -// Define a "trap" when retrieving property values: -function get( obj, prop ) { - if ( prop === 'length' ) { - return obj.length; - } - return obj[ prop ] * 2.0; -} - -// Define the proxy handlers: -handlers = { - 'get': get -}; - -// Create a proxy: -p = new Proxy( arr, handlers ); - -// Access array values... -for ( i = 0; i < p.length; i++ ) { - console.log( 'arr[%d] = %d', i, p[ i ] ); -} 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..9a03b84 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-proxy-support@v0.2.2-esm/index.mjs";var t="undefined"==typeof Proxy?null:Proxy;var e=r()?t:function(r){return r};export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..88b9dc2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js","../lib/polyfill.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Proxy object.\n*\n* @module @stdlib/proxy-ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy-ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert-has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n"],"names":["proxy","Proxy","proxy$1","hasProxySupport","builtin","target"],"mappings":";;mGAgDA,IAAIA,EAA2B,oBAAVC,MAA0B,KAAOA,MCetD,IAAAC,EATKC,IACIC,ECTT,SAAgBC,GAEf,OAAOA,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 18245f7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Proxy object. -* -* @module @stdlib/proxy-ctor -* -* @example -* var Proxy = require( '@stdlib/proxy-ctor' ); -* -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ - -// MODULES // - -var hasProxySupport = require( '@stdlib/assert-has-proxy-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var proxy; -if ( hasProxySupport() ) { - proxy = builtin; -} else { - proxy = polyfill; -} - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 027a357..0000000 --- a/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a proxied object. -* -* @name Proxy -* @constructor -* @type {Function} -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -var proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins - - -// EXPORTS // - -module.exports = proxy; diff --git a/lib/polyfill.js b/lib/polyfill.js deleted file mode 100644 index 9fb7ee4..0000000 --- a/lib/polyfill.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Proxy polyfill. -* -* @private -* @param {Object} target - target object to wrap -* @param {Object} handlers - object whose properties are functions defining proxy behavior -* @returns {Object} proxied object -* -* @example -* function get( obj, prop ) { -* return obj[ prop ] * 2.0; -* } -* -* var handlers = { -* 'get': get -* }; -* -* var p = new Proxy( {}, handlers ); -* -* p.a = 3.14; -* -* var x = p.a; -* // returns 6.28 -*/ -function Proxy( target ) { - // TODO: polyfill implementation - return target; -} - - -// EXPORTS // - -module.exports = Proxy; diff --git a/package.json b/package.json index d4f9a33..a5b28a3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Proxy object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-proxy-support": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "proxy", @@ -74,9 +23,8 @@ "object", "obj" ], - "__stdlib__": {}, "funding": { "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..287961a --- /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 1736659..0000000 --- a/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Proxy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports ES6/ES2015+ `Proxy`, the main export is the `Proxy` global', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './main.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return true; - } -}); - -tape( 'if an environment does not support ES6/ES2015+ `Proxy`, the main export is a polyfill', function test( t ) { - var Proxy; - var mock; - - mock = {}; - Proxy = proxyquire( './../lib', { - '@stdlib/assert-has-proxy-support': hasSupport, - './polyfill.js': mock - }); - - t.strictEqual( Proxy, mock, 'returns expected value' ); - t.end(); - - function hasSupport() { - return false; - } -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - t.deepEqual( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 0090d8a..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Proxy = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Proxy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function proxies a target object', function test( t ) { - var handlers; - var target; - var res; - var o; - var v; - - target = {}; - res = []; - - handlers = { - 'get': get - }; - o = new Proxy( target, handlers ); - - o.beep = 'boop'; - o.foo = 'bar'; - - v = o.beep; - t.strictEqual( v, 'boop', 'returns expected value' ); - - v = o.foo; - t.strictEqual( v, 'bar', 'returns expected value' ); - - // FIXME: don't skip once polyfill implemented - t.skip( res, [ 'beep', 'foo' ], 'contains expected values' ); - - t.end(); - - function get( obj, prop ) { - res.push( prop ); - return obj[ prop ]; - } -}); - -// TODO: additional tests