From f85f36756f4067b2b908f3d98ff0e26c34ed4bb2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Apr 2022 07:09:17 +0000 Subject: [PATCH 001/138] Auto-generated commit d60e3a3cb676e5bc50a51a36f089ecf38cb4e43e --- CONTRIBUTORS | 28 + LICENSE | 481 +++++++++ NOTICE | 1 + README.md | 254 +++++ index.d.ts | 57 ++ index.mjs | 4 + index.mjs.map | 1 + package.json | 49 + stats.html | 2689 +++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 3564 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..5b97b45 --- /dev/null +++ b/README.md @@ -0,0 +1,254 @@ + + +# shift + +[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] + +> Remove and return the first element of a collection. + + + +
+ +
+ + + + + + + +
+ +## Usage + +```javascript +import shift from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-shift@esm/index.mjs'; +``` + +#### shift( collection ) + +Removes and returns the first element of a `collection`. A `collection` may be either an [`Array`][mdn-array], [`Typed Array`][mdn-typed-array], or an array-like [`Object`][mdn-object] (i.e., an [`Object`][mdn-object] having a valid writable `length` property). + +```javascript +var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + +var out = shift( arr ); +// returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] + +var bool = ( out[ 0 ] === arr ); +// returns true + +var lastValue = out[ 1 ]; +// returns 1.0 +``` + +In contrast to [`Array.prototype.shift`][mdn-array-shift] which returns only the removed element, the function also returns the shortened collection. For [typed arrays][mdn-typed-array] having a length greater than `0`, the returned collection is a new [typed array][mdn-typed-array] view. + +```javascript +import Float64Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float64@esm/index.mjs'; + +var arr = new Float64Array( 2 ); +arr[ 0 ] = 1.0; +arr[ 1 ] = 2.0; + +var out = shift( arr ); +// returns [ [ 2.0 ], 1.0 ] + +var bool = ( out[ 0 ] === arr ); +// returns false + +bool = ( out[ 0 ].buffer === arr.buffer ); +// returns true + +var lastValue = out[ 1 ]; +// returns 1.0 +``` + +
+ + + + + +
+ +## Notes + +- When provided a [typed array][mdn-typed-array], the function does **not** change the underlying [`ArrayBuffer`][mdn-arraybuffer]. The function returns a new [typed array][mdn-typed-array] view whose length is one less than the input [typed array][mdn-typed-array] length. Accordingly, the function does **not** reduce the memory footprint of an input [typed array][mdn-typed-array]. + +
+ + + + + +
+ +## 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..e93cdb0 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,57 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2019 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 2.0 + +/// + +import { Collection } from '@stdlib/types/object'; + +/** +* Removes and returns the first element of a collection. +* +* ## Notes +* +* - The function returns an array with two elements: the shortened collection and the removed element. +* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. +* - For purposes of generality, always treat the output collection as distinct from the input collection. +* +* @param collection - collection +* @returns updated collection and the removed element +* +* @example +* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; +* +* var out = shift( arr ); +* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] +* +* @example +* var Float64Array = require( `@stdlib/array/float64` ); +* +* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] +* +* var out = shift( arr ); +* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] +*/ +declare function shift( collection: Collection ): [Collection, any]; + + +// EXPORTS // + +export = shift; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e7cd560 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@esm/index.mjs";var s=e,i=t,o=r,a=n,d=function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n=0)return d(e);throw new TypeError(a("invalid argument. Must provide either an Array, Typed Array, or an array-like object. Value: `%s`.",e))};export{f as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..cd72b0c --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/shift_typed_array.js","../lib/shift.js","../lib/shift_object.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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );\nvar isInteger = require( '@stdlib/assert-is-integer' );\nvar format = require( '@stdlib/string-format' );\nvar shiftObject = require( './shift_object.js' );\nvar shiftTypedArray = require( './shift_typed_array.js' );\n\n\n// MAIN //\n\n/**\n* Removes and returns the first element of a collection.\n*\n* @param {(Array|TypedArray|Object)} collection - collection\n* @throws {TypeError} must provide either an array, typed array, or an array-like object\n* @returns {Array} updated collection and the removed element\n*\n* @example\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an Array, Typed Array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Remove and return the first element of a collection.\n*\n* @module @stdlib/utils-shift\n*\n* @example\n* var shift = require( '@stdlib/utils-shift' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\n\n// MODULES //\n\nvar shift = require( './shift.js' );\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n"],"names":["isArray","require$$0","isTypedArrayLike","require$$1","isInteger","require$$2","format","require$$3","shiftObject","obj","len","v","i","length","shiftTypedArray","arr","offset","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","lib","collection","shift","TypeError"],"mappings":";;uVAsDA,IChCIA,EAAUC,EACVC,EAAmBC,EACnBC,EAAYC,EACZC,EAASC,EACTC,ECaJ,SAAgBC,GACf,IAAIC,EACAC,EACAC,EACJ,GAAoB,IAAfH,EAAII,OACR,MAAO,CAAEJ,OAAK,GAMf,IAJAC,EAAMD,EAAII,OAAS,EACnBF,EAAIF,EAAK,GAGHG,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAKG,GAAMH,EAAKG,EAAE,GAInB,cAFOH,EAAKC,GACZD,EAAII,OAASH,EACN,CAAED,EAAKE,ID5BXG,EDWJ,SAAgBC,GACf,IAAIC,EAEAL,EACJ,OAAoB,IAAfI,EAAIF,OACD,CAAEE,OAAK,IAEfJ,EAAII,EAAK,GACTC,EAASD,EAAIE,WAAaF,EAAIG,kBAEvB,CADA,IAAIH,EAAII,YAAaJ,EAAIK,OAAQJ,EAAQD,EAAIF,OAAO,GAC5CF,KCgChB,IEhCAU,EFMA,SAAgBC,GACf,IAAIX,EACJ,GAAKX,EAASsB,GAEb,OADAX,EAAIW,EAAWC,QACR,CAAED,EAAYX,GAGtB,GAAKT,EAAkBoB,GACtB,OAAOR,EAAiBQ,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWT,QAClBT,EAAWkB,EAAWT,SACtBS,EAAWT,QAAU,EAErB,OAAOL,EAAac,GAErB,MAAM,IAAIE,UAAWlB,EAAQ,qGAAsGgB"} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..c6b6162 --- /dev/null +++ b/package.json @@ -0,0 +1,49 @@ +{ + "name": "@stdlib/utils-shift", + "version": "0.0.0", + "description": "Remove and return the first element of a collection.", + "license": "Apache-2.0", + "type": "module", + "main": "./index.mjs", + "homepage": "https://stdlib.io", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/utils-shift.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "keywords": [ + "stdlib", + "stdutils", + "stdutil", + "utilities", + "utility", + "utils", + "util", + "shift", + "remove", + "delete", + "cut", + "shorten", + "array", + "typed array", + "typed-array", + "float64array", + "float32array", + "int32array", + "uint32array", + "int16array", + "uint16array", + "int8array", + "uint8array", + "uint8clampedarray", + "array-like", + "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..53dd0ee --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + From 5ab99860e6e8312b2ef4eceee386b5bfb76642fd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 00:18:52 +0000 Subject: [PATCH 002/138] Transform error messages --- lib/shift.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/shift.js b/lib/shift.js index 66bb83e..aed36c7 100644 --- a/lib/shift.js +++ b/lib/shift.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); diff --git a/package.json b/package.json index 017a49d..228730f 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.0.x", "@stdlib/assert-is-integer": "^0.0.x", "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From a48bcef76579a746747503a5018e2a40d296bb71 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 08:57:07 +0000 Subject: [PATCH 003/138] Remove files --- index.d.ts | 57 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2751 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 e93cdb0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, any]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e7cd560..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@esm/index.mjs";var s=e,i=t,o=r,a=n,d=function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n=0)return d(e);throw new TypeError(a("invalid argument. Must provide either an Array, Typed Array, or an array-like object. Value: `%s`.",e))};export{f as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index cd72b0c..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/shift_typed_array.js","../lib/shift.js","../lib/shift_object.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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );\nvar isInteger = require( '@stdlib/assert-is-integer' );\nvar format = require( '@stdlib/string-format' );\nvar shiftObject = require( './shift_object.js' );\nvar shiftTypedArray = require( './shift_typed_array.js' );\n\n\n// MAIN //\n\n/**\n* Removes and returns the first element of a collection.\n*\n* @param {(Array|TypedArray|Object)} collection - collection\n* @throws {TypeError} must provide either an array, typed array, or an array-like object\n* @returns {Array} updated collection and the removed element\n*\n* @example\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an Array, Typed Array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Remove and return the first element of a collection.\n*\n* @module @stdlib/utils-shift\n*\n* @example\n* var shift = require( '@stdlib/utils-shift' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\n\n// MODULES //\n\nvar shift = require( './shift.js' );\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n"],"names":["isArray","require$$0","isTypedArrayLike","require$$1","isInteger","require$$2","format","require$$3","shiftObject","obj","len","v","i","length","shiftTypedArray","arr","offset","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","lib","collection","shift","TypeError"],"mappings":";;uVAsDA,IChCIA,EAAUC,EACVC,EAAmBC,EACnBC,EAAYC,EACZC,EAASC,EACTC,ECaJ,SAAgBC,GACf,IAAIC,EACAC,EACAC,EACJ,GAAoB,IAAfH,EAAII,OACR,MAAO,CAAEJ,OAAK,GAMf,IAJAC,EAAMD,EAAII,OAAS,EACnBF,EAAIF,EAAK,GAGHG,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAKG,GAAMH,EAAKG,EAAE,GAInB,cAFOH,EAAKC,GACZD,EAAII,OAASH,EACN,CAAED,EAAKE,ID5BXG,EDWJ,SAAgBC,GACf,IAAIC,EAEAL,EACJ,OAAoB,IAAfI,EAAIF,OACD,CAAEE,OAAK,IAEfJ,EAAII,EAAK,GACTC,EAASD,EAAIE,WAAaF,EAAIG,kBAEvB,CADA,IAAIH,EAAII,YAAaJ,EAAIK,OAAQJ,EAAQD,EAAIF,OAAO,GAC5CF,KCgChB,IEhCAU,EFMA,SAAgBC,GACf,IAAIX,EACJ,GAAKX,EAASsB,GAEb,OADAX,EAAIW,EAAWC,QACR,CAAED,EAAYX,GAGtB,GAAKT,EAAkBoB,GACtB,OAAOR,EAAiBQ,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWT,QAClBT,EAAWkB,EAAWT,SACtBS,EAAWT,QAAU,EAErB,OAAOL,EAAac,GAErB,MAAM,IAAIE,UAAWlB,EAAQ,qGAAsGgB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 53dd0ee..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 08ae2bc26c37480ca4b3d242051553aa75ee760d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 08:57:46 +0000 Subject: [PATCH 004/138] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 681 ------ .github/workflows/publish.yml | 157 -- .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 43 +- benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 --- branches.md | 53 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/shift.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 65 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 206 -- 42 files changed, 2715 insertions(+), 4065 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/shift.js delete mode 100644 lib/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index e522c6b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-06-30T21:59:29.567Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f48b5b2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -177,7 +170,7 @@ console.log( arr ); ## 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]. @@ -249,11 +242,11 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index e02c6d1..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b47953c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index 8bb6214..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index 3c8d32e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 261dc8e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -click B href "https://github.com/stdlib-js/utils-shift/tree/main" -click C href "https://github.com/stdlib-js/utils-shift/tree/production" -click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e8dd002..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, any] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, any] - shift( [ true, false ] ); // $ExpectType [Collection, any] - shift( [ true, true ] ); // $ExpectType [Collection, any] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 55d0ce4..e93cdb0 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2d9a7de --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;gWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,IDcPU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,GFiBNe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a1d14d7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var shift = require( './shift.js' ); - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift.js b/lib/shift.js deleted file mode 100644 index aed36c7..0000000 --- a/lib/shift.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 228730f..fb1717a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Remove and return the first element of a collection.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..589b624 --- /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 53a679f..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From b905bb106ca301e57908d03b6b48aff3701bc298 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 19:54:54 +0000 Subject: [PATCH 005/138] Transform error messages --- lib/shift.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/shift.js b/lib/shift.js index 66bb83e..aed36c7 100644 --- a/lib/shift.js +++ b/lib/shift.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); diff --git a/package.json b/package.json index 017a49d..228730f 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.0.x", "@stdlib/assert-is-integer": "^0.0.x", "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 95fb5746f12148ca6bcc6a96b1332403877ad27b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 10:31:18 +0000 Subject: [PATCH 006/138] Remove files --- index.d.ts | 57 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2751 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 e93cdb0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, any]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2d9a7de..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;gWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,IDcPU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,GFiBNe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 589b624..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From b057abe9cc91c800757d9891b4789fa1c3459c99 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 10:31:55 +0000 Subject: [PATCH 007/138] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 681 ------ .github/workflows/publish.yml | 157 -- .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 43 +- benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 --- branches.md | 53 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/shift.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 65 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 206 -- 42 files changed, 2715 insertions(+), 4065 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/shift.js delete mode 100644 lib/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 781cd21..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-07-01T01:06:43.567Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f48b5b2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -177,7 +170,7 @@ console.log( arr ); ## 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]. @@ -249,11 +242,11 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index e02c6d1..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b47953c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index 8bb6214..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index 3c8d32e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 261dc8e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -click B href "https://github.com/stdlib-js/utils-shift/tree/main" -click C href "https://github.com/stdlib-js/utils-shift/tree/production" -click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e8dd002..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, any] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, any] - shift( [ true, false ] ); // $ExpectType [Collection, any] - shift( [ true, true ] ); // $ExpectType [Collection, any] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 55d0ce4..e93cdb0 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2d9a7de --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;gWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,IDcPU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,GFiBNe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a1d14d7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var shift = require( './shift.js' ); - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift.js b/lib/shift.js deleted file mode 100644 index aed36c7..0000000 --- a/lib/shift.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 228730f..fb1717a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Remove and return the first element of a collection.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..59952e8 --- /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 53a679f..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From 2ecb872a0fad2cdd4e15efc9a32ddc56babe3b10 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 4 Jul 2022 13:35:19 +0000 Subject: [PATCH 008/138] Transform error messages --- lib/shift.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/shift.js b/lib/shift.js index 66bb83e..aed36c7 100644 --- a/lib/shift.js +++ b/lib/shift.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); diff --git a/package.json b/package.json index 017a49d..228730f 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.0.x", "@stdlib/assert-is-integer": "^0.0.x", "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 64c6265b55fc60a624e585ff6424946ea17fc125 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 4 Jul 2022 13:35:42 +0000 Subject: [PATCH 009/138] Remove files --- index.d.ts | 57 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2751 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 e93cdb0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, any]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2d9a7de..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;gWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,IDcPU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,GFiBNe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 59952e8..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From c8f2ce37f73bdb29a504c8a3c3433027339f42f1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 4 Jul 2022 13:36:24 +0000 Subject: [PATCH 010/138] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 687 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 43 +- benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 --- branches.md | 53 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/shift.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 65 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 206 -- 41 files changed, 2715 insertions(+), 4030 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/shift.js delete mode 100644 lib/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f48b5b2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 6726965..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,687 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the repository: - push: - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch or create new branch tag: - - name: 'Push changes to `deno` branch or create new branch tag' - run: | - SLUG=${{ github.repository }} - VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p') - if [ -z "$VERSION" ]; then - echo "Workflow job was not triggered by a new tag...." - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - else - echo "Workflow job was triggered by a new tag: $VERSION" - echo "Creating new bundle branch tag of the form $VERSION-deno" - git tag -a $VERSION-deno -m "$VERSION-deno" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-deno - fi - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -177,7 +170,7 @@ console.log( arr ); ## 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]. @@ -249,11 +242,11 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index e02c6d1..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b47953c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index 8bb6214..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index 3c8d32e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 261dc8e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -click B href "https://github.com/stdlib-js/utils-shift/tree/main" -click C href "https://github.com/stdlib-js/utils-shift/tree/production" -click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e8dd002..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, any] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, any] - shift( [ true, false ] ); // $ExpectType [Collection, any] - shift( [ true, true ] ); // $ExpectType [Collection, any] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 55d0ce4..e93cdb0 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2d9a7de --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;gWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,IDcPU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,GFiBNe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a1d14d7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var shift = require( './shift.js' ); - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift.js b/lib/shift.js deleted file mode 100644 index aed36c7..0000000 --- a/lib/shift.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 228730f..fb1717a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Remove and return the first element of a collection.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..4f429ef --- /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 53a679f..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From ba259c8a7a309481856c1f8c580b2e2692be2e53 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 03:39:07 +0000 Subject: [PATCH 011/138] Transform error messages --- lib/shift.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/shift.js b/lib/shift.js index 66bb83e..aed36c7 100644 --- a/lib/shift.js +++ b/lib/shift.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); diff --git a/package.json b/package.json index 017a49d..228730f 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.0.x", "@stdlib/assert-is-integer": "^0.0.x", "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 5302796a682afd481315f8855931760ce5622367 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 10:47:35 +0000 Subject: [PATCH 012/138] Remove files --- index.d.ts | 57 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2751 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 e93cdb0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, any]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2d9a7de..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;gWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,IDcPU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,GFiBNe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4f429ef..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 0f3a74bb63b854f04f441513cbb9c170375fa0d6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 10:48:30 +0000 Subject: [PATCH 013/138] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 43 +- benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 --- branches.md | 53 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/shift.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 65 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 206 -- 42 files changed, 2715 insertions(+), 4104 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/shift.js delete mode 100644 lib/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index a145e46..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-08-01T01:09:56.943Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f48b5b2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -177,7 +170,7 @@ console.log( arr ); ## 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]. @@ -249,11 +242,11 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index e02c6d1..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b47953c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index 8bb6214..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index 3c8d32e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 261dc8e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -click B href "https://github.com/stdlib-js/utils-shift/tree/main" -click C href "https://github.com/stdlib-js/utils-shift/tree/production" -click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e8dd002..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, any] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, any] - shift( [ true, false ] ); // $ExpectType [Collection, any] - shift( [ true, true ] ); // $ExpectType [Collection, any] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 55d0ce4..e93cdb0 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..3ab4815 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,IDcPU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,GFiBNe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a1d14d7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var shift = require( './shift.js' ); - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift.js b/lib/shift.js deleted file mode 100644 index aed36c7..0000000 --- a/lib/shift.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 228730f..fb1717a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Remove and return the first element of a collection.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2f51446 --- /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 53a679f..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From f0ebf397dda275c41af772720b0da23b2742ebc4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 03:29:41 +0000 Subject: [PATCH 014/138] Transform error messages --- lib/shift.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/shift.js b/lib/shift.js index 66bb83e..aed36c7 100644 --- a/lib/shift.js +++ b/lib/shift.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); diff --git a/package.json b/package.json index 017a49d..228730f 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.0.x", "@stdlib/assert-is-integer": "^0.0.x", "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 1b1f391d6171baa0b68a892456b6a5f7d0630651 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 13:30:40 +0000 Subject: [PATCH 015/138] Remove files --- index.d.ts | 57 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2751 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 e93cdb0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, any]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 3ab4815..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,IDcPU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,GFiBNe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2f51446..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 875f7b6f6c8f09784c4e9a6b40eb6a6c2aafa722 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 13:31:26 +0000 Subject: [PATCH 016/138] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 43 +- benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 --- branches.md | 53 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/shift.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 65 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 206 -- 42 files changed, 2715 insertions(+), 4120 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/shift.js delete mode 100644 lib/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 2af26e1..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-09-01T01:07:34.438Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f48b5b2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -177,7 +170,7 @@ console.log( arr ); ## 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]. @@ -249,11 +242,11 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index e02c6d1..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b47953c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index 8bb6214..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index 3c8d32e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 261dc8e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -click B href "https://github.com/stdlib-js/utils-shift/tree/main" -click C href "https://github.com/stdlib-js/utils-shift/tree/production" -click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e8dd002..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, any] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, any] - shift( [ true, false ] ); // $ExpectType [Collection, any] - shift( [ true, true ] ); // $ExpectType [Collection, any] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 55d0ce4..e93cdb0 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..3ab4815 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,IDcPU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,GFiBNe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a1d14d7..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var shift = require( './shift.js' ); - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift.js b/lib/shift.js deleted file mode 100644 index aed36c7..0000000 --- a/lib/shift.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 228730f..fb1717a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Remove and return the first element of a collection.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..5fe63a1 --- /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 53a679f..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From f1917ae3e7bf9ac10cc9e1d442638b347d3244de Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Sep 2022 00:55:39 +0000 Subject: [PATCH 017/138] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..aed36c7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); diff --git a/package.json b/package.json index 017a49d..228730f 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.0.x", "@stdlib/assert-is-integer": "^0.0.x", "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 14197575b0354e789f63cfa56b3ab2f9a66ef900 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Sep 2022 00:57:46 +0000 Subject: [PATCH 018/138] Remove files --- index.d.ts | 57 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2751 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 e93cdb0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, any]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 3ab4815..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,IDcPU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,GFiBNe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5fe63a1..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 68ce8d7a1ddca47771cb46e6dbbbdcf048190190 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Sep 2022 00:58:41 +0000 Subject: [PATCH 019/138] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 43 +- benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 --- branches.md | 53 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 65 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 206 -- 41 files changed, 2715 insertions(+), 4119 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f48b5b2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -177,7 +170,7 @@ console.log( arr ); ## 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]. @@ -249,11 +242,11 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index e02c6d1..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b47953c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index 8bb6214..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index 3c8d32e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 261dc8e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -click B href "https://github.com/stdlib-js/utils-shift/tree/main" -click C href "https://github.com/stdlib-js/utils-shift/tree/production" -click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e8dd002..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, any] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, any] - shift( [ true, false ] ); // $ExpectType [Collection, any] - shift( [ true, true ] ); // $ExpectType [Collection, any] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 55d0ce4..e93cdb0 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..3ab4815 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,IDcPU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,GFiBNe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e63a365..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var shift = require( './main.js' ); - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index aed36c7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 228730f..fb1717a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Remove and return the first element of a collection.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..d6d27c6 --- /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 53a679f..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From f63363c2b68109aee6136eb245a472b506ecfa80 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 04:39:05 +0000 Subject: [PATCH 020/138] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..aed36c7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); diff --git a/package.json b/package.json index 017a49d..228730f 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.0.x", "@stdlib/assert-is-integer": "^0.0.x", "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 2da90b77a5bbe052c3b3d4ac95203d197a1e8222 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 2 Oct 2022 00:34:28 +0000 Subject: [PATCH 021/138] Remove files --- index.d.ts | 57 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2751 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 e93cdb0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, any]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 3ab4815..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,IDcPU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,GFiBNe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d6d27c6..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 29fda6504160e34b21e931a6cb16bdd0f1a2c1ef Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 2 Oct 2022 00:35:09 +0000 Subject: [PATCH 022/138] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 43 +- benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 --- branches.md | 53 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 65 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 206 -- 42 files changed, 2715 insertions(+), 4120 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 8521bb1..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-10-01T01:32:20.224Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f48b5b2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -177,7 +170,7 @@ console.log( arr ); ## 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]. @@ -249,11 +242,11 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index e02c6d1..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b47953c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index 8bb6214..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index 3c8d32e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 261dc8e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -click B href "https://github.com/stdlib-js/utils-shift/tree/main" -click C href "https://github.com/stdlib-js/utils-shift/tree/production" -click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e8dd002..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, any] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, any] - shift( [ true, false ] ); // $ExpectType [Collection, any] - shift( [ true, true ] ); // $ExpectType [Collection, any] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 55d0ce4..e93cdb0 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..3ab4815 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,IDcPU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,GFiBNe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index aed36c7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 228730f..fb1717a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Remove and return the first element of a collection.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..4b42be0 --- /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 53a679f..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From 6f04caa94d873d7cf8a465ab0133f0bb666f9b32 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 02:26:38 +0000 Subject: [PATCH 023/138] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..aed36c7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); diff --git a/package.json b/package.json index 017a49d..228730f 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.0.x", "@stdlib/assert-is-integer": "^0.0.x", "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From a2bcbeecd8d5adaabf26b25d5abf055142fc3c9b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 18:49:24 +0000 Subject: [PATCH 024/138] Remove files --- index.d.ts | 57 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2751 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 e93cdb0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, any]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 3ab4815..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,IDcPU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,GFiBNe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4b42be0..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From a9f5db20897eea02718ac0a6937f9c3252107027 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 18:50:12 +0000 Subject: [PATCH 025/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 43 +- benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 -- branches.md | 53 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 65 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 206 -- 42 files changed, 4070 insertions(+), 4120 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index bb0dcc8..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-01T01:20:35.867Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f48b5b2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 db2b0df..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: '50 14 * * 1' - - # 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 + + ```
@@ -177,7 +170,7 @@ console.log( arr ); ## 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]. @@ -249,11 +242,11 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index e02c6d1..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b47953c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index 8bb6214..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index 3c8d32e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 261dc8e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -click B href "https://github.com/stdlib-js/utils-shift/tree/main" -click C href "https://github.com/stdlib-js/utils-shift/tree/production" -click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e8dd002..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, any] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, any] - shift( [ true, false ] ); // $ExpectType [Collection, any] - shift( [ true, true ] ); // $ExpectType [Collection, any] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 55d0ce4..e93cdb0 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..3ab4815 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB,GACpI"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index aed36c7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 228730f..fb1717a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Remove and return the first element of a collection.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..d9f06e0 --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From 2717376bae71a535bce40294e304c3fc13931dd9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 00:05:46 +0000 Subject: [PATCH 026/138] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..aed36c7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); diff --git a/package.json b/package.json index 017a49d..228730f 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.0.x", "@stdlib/assert-is-integer": "^0.0.x", "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 4047fd51c21876ed1cc0a858da0c49acadd6130d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 13:19:58 +0000 Subject: [PATCH 027/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4106 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 e93cdb0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, any]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 3ab4815..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB,GACpI"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d9f06e0..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 7adfd6ed85f229db05a883482393fee7393f81cf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 13:20:53 +0000 Subject: [PATCH 028/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 781 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 43 +- benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 -- branches.md | 53 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 65 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 206 -- 42 files changed, 4070 insertions(+), 4141 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 49fa7b2..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-03T21:53:23.709Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f48b5b2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 db2b0df..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: '50 14 * * 1' - - # 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 + + ```
@@ -177,7 +170,7 @@ console.log( arr ); ## 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]. @@ -249,11 +242,11 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index e02c6d1..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b47953c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index 8bb6214..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index 3c8d32e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 261dc8e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -click B href "https://github.com/stdlib-js/utils-shift/tree/main" -click C href "https://github.com/stdlib-js/utils-shift/tree/production" -click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e8dd002..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, any] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, any] - shift( [ true, false ] ); // $ExpectType [Collection, any] - shift( [ true, true ] ); // $ExpectType [Collection, any] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 55d0ce4..e93cdb0 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..3ab4815 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB,GACpI"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index aed36c7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 228730f..fb1717a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Remove and return the first element of a collection.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..e562b1d --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From 1fae943b01e84f1980c8f1526072085657c52375 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 03:57:20 +0000 Subject: [PATCH 029/138] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..aed36c7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); diff --git a/package.json b/package.json index a346d99..4d2be6a 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.0.x", "@stdlib/assert-is-integer": "^0.0.x", "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 3e143642d9aaf2d6c2713c9cff0a54b0da647989 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 11:23:17 +0000 Subject: [PATCH 030/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4106 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 e93cdb0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, any]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 3ab4815..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB,GACpI"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e562b1d..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From c954ba0cc83b5ab3aed0449c90f1e3db653dcc99 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 11:23:57 +0000 Subject: [PATCH 031/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 781 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 183 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 43 +- benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 -- branches.md | 53 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 65 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 206 -- 42 files changed, 4070 insertions(+), 4146 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index bf7b3b6..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-12-01T01:43:14.026Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f48b5b2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 db2b0df..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: '50 14 * * 1' - - # 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 + + ```
@@ -177,7 +170,7 @@ console.log( arr ); ## 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]. @@ -249,11 +242,11 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index e02c6d1..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b47953c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index 8bb6214..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index 3c8d32e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 261dc8e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -click B href "https://github.com/stdlib-js/utils-shift/tree/main" -click C href "https://github.com/stdlib-js/utils-shift/tree/production" -click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e8dd002..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, any] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, any] - shift( [ true, false ] ); // $ExpectType [Collection, any] - shift( [ true, true ] ); // $ExpectType [Collection, any] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 55d0ce4..e93cdb0 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..3ab4815 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB,GACpI"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index aed36c7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 4d2be6a..fb1717a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Remove and return the first element of a collection.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "2.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..1d5978c --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From cca8aaf245aade39ab0d241003a30354844db8c5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 02:53:55 +0000 Subject: [PATCH 032/138] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..aed36c7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); diff --git a/package.json b/package.json index a0e9d1e..3c2b47e 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.0.x", "@stdlib/assert-is-integer": "^0.0.x", "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From c496879699f4d0c717c838bb0ee7d204506c3316 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 07:22:43 +0000 Subject: [PATCH 033/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4106 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 e93cdb0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, any]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 3ab4815..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB,GACpI"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 1d5978c..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 2e0c783af6b8bbbed8735f5815976058ad4e6e9f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 07:23:36 +0000 Subject: [PATCH 034/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 791 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 184 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 43 +- benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 -- branches.md | 53 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 65 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 206 -- 42 files changed, 4070 insertions(+), 4157 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index a5cd62d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-01-01T01:10:33.301Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f48b5b2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 db2b0df..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: '50 14 * * 1' - - # 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 + + ```
@@ -177,7 +170,7 @@ console.log( arr ); ## 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]. @@ -249,11 +242,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index e02c6d1..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b47953c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index 8bb6214..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index 3c8d32e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 261dc8e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -click B href "https://github.com/stdlib-js/utils-shift/tree/main" -click C href "https://github.com/stdlib-js/utils-shift/tree/production" -click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e8dd002..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, any] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, any] - shift( [ true, false ] ); // $ExpectType [Collection, any] - shift( [ true, true ] ); // $ExpectType [Collection, any] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 55d0ce4..e93cdb0 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5e857cf --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB,GACpI"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index aed36c7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 3c2b47e..fb1717a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Remove and return the first element of a collection.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..3c75ddd --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From 927d804f2fe373f46358e255c28bac12af1044ff Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 04:21:55 +0000 Subject: [PATCH 035/138] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..aed36c7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); diff --git a/package.json b/package.json index a0e9d1e..3c2b47e 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.0.x", "@stdlib/assert-is-integer": "^0.0.x", "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From e2ebebec0bd6f1bd7ee7dccc97e355024f413342 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 13:23:13 +0000 Subject: [PATCH 036/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4106 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 e93cdb0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, any]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 5e857cf..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB,GACpI"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 3c75ddd..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From a54763686c3bd0471de988a604c391ccd5409a20 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 13:24:05 +0000 Subject: [PATCH 037/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 791 --- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 184 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 - branches.md | 53 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 65 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 206 - 42 files changed, 6203 insertions(+), 4157 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index b3ca6fc..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-02-01T01:32:24.439Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f48b5b2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 db2b0df..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: '50 14 * * 1' - - # 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 + + ```
@@ -177,7 +170,7 @@ console.log( arr ); ## 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]. @@ -249,11 +242,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index e02c6d1..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b47953c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index 8bb6214..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index 3c8d32e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 261dc8e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -click B href "https://github.com/stdlib-js/utils-shift/tree/main" -click C href "https://github.com/stdlib-js/utils-shift/tree/production" -click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e8dd002..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, any] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, any] - shift( [ true, false ] ); // $ExpectType [Collection, any] - shift( [ true, true ] ); // $ExpectType [Collection, any] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 55d0ce4..e93cdb0 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5e857cf --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB,GACpI"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index aed36c7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 3c2b47e..fb1717a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Remove and return the first element of a collection.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-integer": "^0.0.x", - "@stdlib/assert-is-typed-array-like": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c9f9275 --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From bc8ba1d5ed89f40c8798b18c4f809a33ccf09115 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 05:38:41 +0000 Subject: [PATCH 038/138] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..aed36c7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); diff --git a/package.json b/package.json index 5e0a178..d41029e 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.0.7", "@stdlib/assert-is-integer": "^0.0.8", "@stdlib/assert-is-typed-array-like": "^0.0.8", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14" }, "devDependencies": { From 74c6a5254032e6835959ee103235d68080d92931 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 13:58:49 +0000 Subject: [PATCH 039/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6239 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 e93cdb0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, any]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 5e857cf..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB,GACpI"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c9f9275..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 231c2bf72da357dffe7e5959c88d25b69aeb246c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 13:59:40 +0000 Subject: [PATCH 040/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 236 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 - branches.md | 53 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 65 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 206 - 42 files changed, 6203 insertions(+), 4292 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 9382ec3..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-03-01T03:38:25.790Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f48b5b2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 db2b0df..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: '50 14 * * 1' - - # 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 + + ```
@@ -177,7 +170,7 @@ console.log( arr ); ## 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]. @@ -249,11 +242,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index e02c6d1..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b47953c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index 8bb6214..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index 3c8d32e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 63e2f80..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e8dd002..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, any] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, any] - shift( [ true, false ] ); // $ExpectType [Collection, any] - shift( [ true, true ] ); // $ExpectType [Collection, any] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 55d0ce4..e93cdb0 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5e857cf --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB,GACpI"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index aed36c7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index d41029e..1aff33c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Remove and return the first element of a collection.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.7", - "@stdlib/assert-is-integer": "^0.0.8", - "@stdlib/assert-is-typed-array-like": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.6", - "@stdlib/array-float32": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/array-int16": "^0.0.6", - "@stdlib/array-int32": "^0.0.6", - "@stdlib/array-int8": "^0.0.6", - "@stdlib/array-uint16": "^0.0.6", - "@stdlib/array-uint32": "^0.0.6", - "@stdlib/array-uint8": "^0.0.7", - "@stdlib/array-uint8c": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..39a8286 --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From 0909573370a501c90c51eafa3e09337441e9c885 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 06:11:06 +0000 Subject: [PATCH 041/138] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..aed36c7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); diff --git a/package.json b/package.json index 5e0a178..d41029e 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.0.7", "@stdlib/assert-is-integer": "^0.0.8", "@stdlib/assert-is-typed-array-like": "^0.0.8", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14" }, "devDependencies": { From 673d0107027239201325484e705500b9826e20bd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 12:57:57 +0000 Subject: [PATCH 042/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6239 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 e93cdb0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, any]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 5e857cf..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB,GACpI"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 39a8286..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a71d1279c7e0c069239a4a3e0abf7d0cae95dc35 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 12:58:46 +0000 Subject: [PATCH 043/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 - branches.md | 53 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 65 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 206 - 42 files changed, 6203 insertions(+), 4298 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index c084b77..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-04-01T04:09:03.425Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f48b5b2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 db2b0df..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: '50 14 * * 1' - - # 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 + + ```
@@ -177,7 +170,7 @@ console.log( arr ); ## 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]. @@ -249,11 +242,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index e02c6d1..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b47953c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index 8bb6214..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index 3c8d32e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 63e2f80..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e8dd002..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, any] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, any] - shift( [ true, false ] ); // $ExpectType [Collection, any] - shift( [ true, true ] ); // $ExpectType [Collection, any] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 55d0ce4..e93cdb0 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5e857cf --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB,GACpI"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index aed36c7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index d41029e..1aff33c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Remove and return the first element of a collection.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.7", - "@stdlib/assert-is-integer": "^0.0.8", - "@stdlib/assert-is-typed-array-like": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.6", - "@stdlib/array-float32": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/array-int16": "^0.0.6", - "@stdlib/array-int32": "^0.0.6", - "@stdlib/array-int8": "^0.0.6", - "@stdlib/array-uint16": "^0.0.6", - "@stdlib/array-uint32": "^0.0.6", - "@stdlib/array-uint8": "^0.0.7", - "@stdlib/array-uint8c": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..bda54c8 --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From 017478f69585f30d0d47474ab626f0e09dce0298 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 05:55:46 +0000 Subject: [PATCH 044/138] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..aed36c7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); diff --git a/package.json b/package.json index 5e0a178..d41029e 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.0.7", "@stdlib/assert-is-integer": "^0.0.8", "@stdlib/assert-is-typed-array-like": "^0.0.8", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14" }, "devDependencies": { From 048c80bb66aaac496a01e21941107ce261650787 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 12:40:14 +0000 Subject: [PATCH 045/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6239 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 e93cdb0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, any]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 5e857cf..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB,GACpI"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index bda54c8..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e025992bc5aec014f61567f852ef35218a29eec9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 12:41:06 +0000 Subject: [PATCH 046/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 - branches.md | 53 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 65 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 206 - 42 files changed, 6203 insertions(+), 4298 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index c0ce6d4..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-05-01T03:56:42.515Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f48b5b2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 db2b0df..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: '50 14 * * 1' - - # 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 + + ```
@@ -177,7 +170,7 @@ console.log( arr ); ## 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]. @@ -249,11 +242,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index e02c6d1..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b47953c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index 8bb6214..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index 3c8d32e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 63e2f80..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e8dd002..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, any] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, any] - shift( [ true, false ] ); // $ExpectType [Collection, any] - shift( [ true, true ] ); // $ExpectType [Collection, any] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 55d0ce4..e93cdb0 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5e857cf --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB,GACpI"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index aed36c7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index d41029e..1aff33c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Remove and return the first element of a collection.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.7", - "@stdlib/assert-is-integer": "^0.0.8", - "@stdlib/assert-is-typed-array-like": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.6", - "@stdlib/array-float32": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/array-int16": "^0.0.6", - "@stdlib/array-int32": "^0.0.6", - "@stdlib/array-int8": "^0.0.6", - "@stdlib/array-uint16": "^0.0.6", - "@stdlib/array-uint32": "^0.0.6", - "@stdlib/array-uint8": "^0.0.7", - "@stdlib/array-uint8c": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..0d7d6a9 --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From 04a0406d5400da5ca30475a4db1cdbff21b45dbf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 05:38:04 +0000 Subject: [PATCH 047/138] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..aed36c7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); diff --git a/package.json b/package.json index 5e0a178..d41029e 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.0.7", "@stdlib/assert-is-integer": "^0.0.8", "@stdlib/assert-is-typed-array-like": "^0.0.8", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14" }, "devDependencies": { From 30fddad7954cce505fb9467fe8126fe5c3751130 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 13:05:17 +0000 Subject: [PATCH 048/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6239 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 e93cdb0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, any]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 5e857cf..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB,GACpI"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0d7d6a9..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c83a80f37cbdeff21151a46f03eca7caa308edaf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 13:05:57 +0000 Subject: [PATCH 049/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 - branches.md | 53 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 65 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 206 - 42 files changed, 6203 insertions(+), 4298 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 3469a70..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-06-01T03:38:22.973Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f48b5b2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 db2b0df..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: '50 14 * * 1' - - # 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 + + ```
@@ -177,7 +170,7 @@ console.log( arr ); ## 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]. @@ -249,11 +242,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index e02c6d1..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b47953c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index 8bb6214..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index 3c8d32e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 63e2f80..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e8dd002..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, any] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, any] - shift( [ true, false ] ); // $ExpectType [Collection, any] - shift( [ true, true ] ); // $ExpectType [Collection, any] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 55d0ce4..e93cdb0 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5e857cf --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB,GACpI"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index aed36c7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index d41029e..1aff33c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Remove and return the first element of a collection.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.7", - "@stdlib/assert-is-integer": "^0.0.8", - "@stdlib/assert-is-typed-array-like": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.6", - "@stdlib/array-float32": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/array-int16": "^0.0.6", - "@stdlib/array-int32": "^0.0.6", - "@stdlib/array-int8": "^0.0.6", - "@stdlib/array-uint16": "^0.0.6", - "@stdlib/array-uint32": "^0.0.6", - "@stdlib/array-uint8": "^0.0.7", - "@stdlib/array-uint8c": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7687469 --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From ac7f3db1cd158f257538d217c6aa65d7e3b76b98 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 28 Jun 2023 03:24:47 +0000 Subject: [PATCH 050/138] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..aed36c7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); diff --git a/package.json b/package.json index 5e0a178..d41029e 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.0.7", "@stdlib/assert-is-integer": "^0.0.8", "@stdlib/assert-is-typed-array-like": "^0.0.8", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14" }, "devDependencies": { From 0005f5961171a2394a770d398dae4c39dc0d8240 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 28 Jun 2023 03:25:40 +0000 Subject: [PATCH 051/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6239 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 e93cdb0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, any]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 5e857cf..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB,GACpI"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7687469..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 088ac828c3c03a9d3c777644ab310895a050c5d2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 28 Jun 2023 03:26:44 +0000 Subject: [PATCH 052/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 - branches.md | 53 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 65 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 206 - 41 files changed, 6203 insertions(+), 4297 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f48b5b2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 db2b0df..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: '50 14 * * 1' - - # 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 + + ```
@@ -177,7 +170,7 @@ console.log( arr ); ## 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]. @@ -249,11 +242,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index e02c6d1..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b47953c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index 8bb6214..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index 3c8d32e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 63e2f80..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e5ceaac..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, number] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, string] - shift( [ true, false ] ); // $ExpectType [Collection, boolean] - shift( [ true, true ] ); // $ExpectType [Collection, boolean] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 237e9d8..bbd0f0d 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5e857cf --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB,GACpI"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index aed36c7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index d41029e..1aff33c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Remove and return the first element of a collection.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.7", - "@stdlib/assert-is-integer": "^0.0.8", - "@stdlib/assert-is-typed-array-like": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.6", - "@stdlib/array-float32": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/array-int16": "^0.0.6", - "@stdlib/array-int32": "^0.0.6", - "@stdlib/array-int8": "^0.0.6", - "@stdlib/array-uint16": "^0.0.6", - "@stdlib/array-uint32": "^0.0.6", - "@stdlib/array-uint8": "^0.0.7", - "@stdlib/array-uint8c": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c724bed --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From f7db3000f2e247fbcb0a8f79e8da8baf0435a35d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 05:40:32 +0000 Subject: [PATCH 053/138] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..aed36c7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); diff --git a/package.json b/package.json index 5e0a178..d41029e 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.0.7", "@stdlib/assert-is-integer": "^0.0.8", "@stdlib/assert-is-typed-array-like": "^0.0.8", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14" }, "devDependencies": { From 52bb2c8f0c34d6bb56976f5d6e148707c10965ea Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 13:17:29 +0000 Subject: [PATCH 054/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6239 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 bbd0f0d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, T]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 5e857cf..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB,GACpI"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c724bed..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 219ae936219e502a822e42735d4499d1efcdd79b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 13:18:06 +0000 Subject: [PATCH 055/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 - branches.md | 53 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 65 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 206 - 42 files changed, 6203 insertions(+), 4298 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index af8db70..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-07-01T03:39:39.354Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f48b5b2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 db2b0df..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: '50 14 * * 1' - - # 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 + + ```
@@ -177,7 +170,7 @@ console.log( arr ); ## 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]. @@ -249,11 +242,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index e02c6d1..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b47953c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index 8bb6214..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index 3c8d32e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 63e2f80..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e5ceaac..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, number] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, string] - shift( [ true, false ] ); // $ExpectType [Collection, boolean] - shift( [ true, true ] ); // $ExpectType [Collection, boolean] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 237e9d8..bbd0f0d 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5e857cf --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB,GACpI"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index aed36c7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index d41029e..1aff33c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Remove and return the first element of a collection.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.7", - "@stdlib/assert-is-integer": "^0.0.8", - "@stdlib/assert-is-typed-array-like": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.6", - "@stdlib/array-float32": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/array-int16": "^0.0.6", - "@stdlib/array-int32": "^0.0.6", - "@stdlib/array-int8": "^0.0.6", - "@stdlib/array-uint16": "^0.0.6", - "@stdlib/array-uint32": "^0.0.6", - "@stdlib/array-uint8": "^0.0.7", - "@stdlib/array-uint8c": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..83a9815 --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From 95d87f631694e547f21ac52a4a3baf9d9ed70500 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 06:05:50 +0000 Subject: [PATCH 056/138] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..aed36c7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); diff --git a/package.json b/package.json index 5e0a178..d41029e 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.0.7", "@stdlib/assert-is-integer": "^0.0.8", "@stdlib/assert-is-typed-array-like": "^0.0.8", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14" }, "devDependencies": { From 450ede9f73e1ae9674463d3b39884dc9b9899fea Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 13:55:28 +0000 Subject: [PATCH 057/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6239 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 bbd0f0d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, T]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 5e857cf..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB,GACpI"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 83a9815..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From fecfa2787d9fc23595779d5b6f68d53412b4b26d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 13:56:08 +0000 Subject: [PATCH 058/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 - branches.md | 53 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 65 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 206 - 42 files changed, 6203 insertions(+), 4298 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index c865399..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-08-01T04:00:32.090Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f48b5b2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 db2b0df..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: '50 14 * * 1' - - # 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 + + ```
@@ -177,7 +170,7 @@ console.log( arr ); ## 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]. @@ -249,11 +242,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index e02c6d1..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b47953c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index 8bb6214..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index 3c8d32e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 63e2f80..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e5ceaac..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, number] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, string] - shift( [ true, false ] ); // $ExpectType [Collection, boolean] - shift( [ true, true ] ); // $ExpectType [Collection, boolean] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 237e9d8..bbd0f0d 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5e857cf --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB,GACpI"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index aed36c7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index d41029e..1aff33c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Remove and return the first element of a collection.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.7", - "@stdlib/assert-is-integer": "^0.0.8", - "@stdlib/assert-is-typed-array-like": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.6", - "@stdlib/array-float32": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/array-int16": "^0.0.6", - "@stdlib/array-int32": "^0.0.6", - "@stdlib/array-int8": "^0.0.6", - "@stdlib/array-uint16": "^0.0.6", - "@stdlib/array-uint32": "^0.0.6", - "@stdlib/array-uint8": "^0.0.7", - "@stdlib/array-uint8c": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..164f5b0 --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From ac2ca8c0bf00fa3092d4e215e79119703b4cc956 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 18 Aug 2023 09:08:47 +0000 Subject: [PATCH 059/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..6300fde 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); @@ -72,7 +72,7 @@ function shift( collection ) { ) { return shiftObject( collection ); } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); + throw new TypeError( format( '1XXBm,OR', collection ) ); } diff --git a/package.json b/package.json index 5e0a178..d41029e 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.0.7", "@stdlib/assert-is-integer": "^0.0.8", "@stdlib/assert-is-typed-array-like": "^0.0.8", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14" }, "devDependencies": { From 8adce5568cb69e7eb9d5fcc06fe71a488cc4e642 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 18 Aug 2023 09:09:56 +0000 Subject: [PATCH 060/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6239 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 bbd0f0d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, T]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 5e857cf..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s){var i;if(e(s))return i=s.shift(),[s,i];if(t(s))return function(e){var t,r;return 0===e.length?[e,void 0]:(r=e[0],t=e.byteOffset+e.BYTES_PER_ELEMENT,[new e.constructor(e.buffer,t,e.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(e){var t,r,n;if(0===e.length)return[e,void 0];for(t=e.length-1,r=e[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB,GACpI"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 164f5b0..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0aab94c07511989f1c4b776ef58d877699564c0f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 18 Aug 2023 09:10:52 +0000 Subject: [PATCH 061/138] 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 | 43 +- benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 9 - dist/index.js.map | 7 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 65 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 206 - 44 files changed, 6203 insertions(+), 4301 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f48b5b2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 db2b0df..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: '50 14 * * 1' - - # 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 + + ```
@@ -177,7 +170,7 @@ console.log( arr ); ## 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]. @@ -249,11 +242,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index e02c6d1..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b47953c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index 8bb6214..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index 3c8d32e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 63e2f80..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6be7628..0000000 --- a/dist/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var f=u(function(k,s){ -function y(r){var e,i,t;if(r.length===0)return[r,void 0];for(e=r.length-1,i=r[0],t=0;t=0)return T(r);throw new TypeError(E('1XXBm',r))}v.exports=w -});var x=h();module.exports=x; -/** @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 af2e9c8..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/shift_object.js", "../lib/shift_typed_array.js", "../lib/main.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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );\nvar isInteger = require( '@stdlib/assert-is-integer' );\nvar format = require( '@stdlib/string-format' );\nvar shiftObject = require( './shift_object.js' );\nvar shiftTypedArray = require( './shift_typed_array.js' );\n\n\n// MAIN //\n\n/**\n* Removes and returns the first element of a collection.\n*\n* @param {(Array|TypedArray|Object)} collection - collection\n* @throws {TypeError} must provide either an array, typed array, or an array-like object\n* @returns {Array} updated collection and the removed element\n*\n* @example\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Remove and return the first element of a collection.\n*\n* @module @stdlib/utils-shift\n*\n* @example\n* var shift = require( '@stdlib/utils-shift' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,GAAKH,EAAI,SAAW,EACnB,MAAO,CAAEA,EAAK,MAAO,EAMtB,IAJAC,EAAMD,EAAI,OAAS,EACnBE,EAAIF,EAAK,CAAE,EAGLG,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAKG,CAAE,EAAIH,EAAKG,EAAE,CAAE,EAErB,cAAOH,EAAKC,CAAI,EAChBD,EAAI,OAASC,EACN,CAAED,EAAKE,CAAE,CACjB,CAKAJ,EAAO,QAAUC,IC7DjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,OAAKH,EAAI,SAAW,EACZ,CAAEA,EAAK,MAAO,GAEtBG,EAAIH,EAAK,CAAE,EACXC,EAASD,EAAI,WAAaA,EAAI,kBAC9BE,EAAO,IAAIF,EAAI,YAAaA,EAAI,OAAQC,EAAQD,EAAI,OAAO,CAAE,EACtD,CAAEE,EAAMC,CAAE,EAClB,CAKAL,EAAO,QAAUC,ICtDjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,yBAA0B,EAC7CC,EAAmB,QAAS,oCAAqC,EACjEC,EAAY,QAAS,2BAA4B,EACjDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAc,IACdC,EAAkB,IA2BtB,SAASC,EAAOC,EAAa,CAC5B,IAAIC,EACJ,GAAKR,EAASO,CAAW,EACxB,OAAAC,EAAID,EAAW,MAAM,EACd,CAAEA,EAAYC,CAAE,EAGxB,GAAKP,EAAkBM,CAAW,EACjC,OAAOF,EAAiBE,CAAW,EAGpC,GACCA,IAAe,MACf,OAAOA,GAAe,UACtB,OAAOA,EAAW,QAAW,UAC7BL,EAAWK,EAAW,MAAO,GAC7BA,EAAW,QAAU,EAErB,OAAOH,EAAaG,CAAW,EAEhC,MAAM,IAAI,UAAWJ,EAAQ,qGAAsGI,CAAW,CAAE,CACjJ,CAKAR,EAAO,QAAUO,ICrCjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_shift_object", "__commonJSMin", "exports", "module", "shift", "obj", "len", "v", "i", "require_shift_typed_array", "__commonJSMin", "exports", "module", "shift", "arr", "offset", "view", "v", "require_main", "__commonJSMin", "exports", "module", "isArray", "isTypedArrayLike", "isInteger", "format", "shiftObject", "shiftTypedArray", "shift", "collection", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e5ceaac..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, number] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, string] - shift( [ true, false ] ); // $ExpectType [Collection, boolean] - shift( [ true, true ] ); // $ExpectType [Collection, boolean] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 9b76edc..d596d8e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d472800 --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm,OR', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,WAAYlB,GAC1C"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 6300fde..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( '1XXBm,OR', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index d41029e..1aff33c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Remove and return the first element of a collection.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.7", - "@stdlib/assert-is-integer": "^0.0.8", - "@stdlib/assert-is-typed-array-like": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.6", - "@stdlib/array-float32": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/array-int16": "^0.0.6", - "@stdlib/array-int32": "^0.0.6", - "@stdlib/array-int8": "^0.0.6", - "@stdlib/array-uint16": "^0.0.6", - "@stdlib/array-uint32": "^0.0.6", - "@stdlib/array-uint8": "^0.0.7", - "@stdlib/array-uint8c": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..d06376c --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From e89022d44fe1cd831d30eee438dab6b5e98d6494 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 15:32:53 +0000 Subject: [PATCH 062/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..6300fde 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); @@ -72,7 +72,7 @@ function shift( collection ) { ) { return shiftObject( collection ); } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); + throw new TypeError( format( '1XXBm,OR', collection ) ); } diff --git a/package.json b/package.json index 44e2e58..59d89ef 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.1.0", "@stdlib/assert-is-integer": "^0.1.0", "@stdlib/assert-is-typed-array-like": "^0.1.0", - "@stdlib/string-format": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0", "@stdlib/types": "^0.1.0" }, "devDependencies": { From bf9f3120b4691d3b99933293d037cad90bbc9017 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 16:55:10 +0000 Subject: [PATCH 063/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6239 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 d596d8e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, T]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d472800..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm,OR', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;uWAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,WAAYlB,GAC1C"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d06376c..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From acd3272a4010baf4cac09a15bf9436efdbc9db92 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 16:55:49 +0000 Subject: [PATCH 064/138] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 783 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 9 - dist/index.js.map | 7 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 65 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 206 - 45 files changed, 6203 insertions(+), 4336 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f48b5b2..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 db2b0df..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: '50 14 * * 1' - - # 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 + + ```
@@ -188,7 +181,7 @@ console.log( arr ); ## 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]. @@ -260,11 +253,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index e02c6d1..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b47953c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index 8bb6214..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index 3c8d32e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 63e2f80..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6be7628..0000000 --- a/dist/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var f=u(function(k,s){ -function y(r){var e,i,t;if(r.length===0)return[r,void 0];for(e=r.length-1,i=r[0],t=0;t=0)return T(r);throw new TypeError(E('1XXBm',r))}v.exports=w -});var x=h();module.exports=x; -/** @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 af2e9c8..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/shift_object.js", "../lib/shift_typed_array.js", "../lib/main.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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );\nvar isInteger = require( '@stdlib/assert-is-integer' );\nvar format = require( '@stdlib/string-format' );\nvar shiftObject = require( './shift_object.js' );\nvar shiftTypedArray = require( './shift_typed_array.js' );\n\n\n// MAIN //\n\n/**\n* Removes and returns the first element of a collection.\n*\n* @param {(Array|TypedArray|Object)} collection - collection\n* @throws {TypeError} must provide either an array, typed array, or an array-like object\n* @returns {Array} updated collection and the removed element\n*\n* @example\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Remove and return the first element of a collection.\n*\n* @module @stdlib/utils-shift\n*\n* @example\n* var shift = require( '@stdlib/utils-shift' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,GAAKH,EAAI,SAAW,EACnB,MAAO,CAAEA,EAAK,MAAO,EAMtB,IAJAC,EAAMD,EAAI,OAAS,EACnBE,EAAIF,EAAK,CAAE,EAGLG,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAKG,CAAE,EAAIH,EAAKG,EAAE,CAAE,EAErB,cAAOH,EAAKC,CAAI,EAChBD,EAAI,OAASC,EACN,CAAED,EAAKE,CAAE,CACjB,CAKAJ,EAAO,QAAUC,IC7DjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,OAAKH,EAAI,SAAW,EACZ,CAAEA,EAAK,MAAO,GAEtBG,EAAIH,EAAK,CAAE,EACXC,EAASD,EAAI,WAAaA,EAAI,kBAC9BE,EAAO,IAAIF,EAAI,YAAaA,EAAI,OAAQC,EAAQD,EAAI,OAAO,CAAE,EACtD,CAAEE,EAAMC,CAAE,EAClB,CAKAL,EAAO,QAAUC,ICtDjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,yBAA0B,EAC7CC,EAAmB,QAAS,oCAAqC,EACjEC,EAAY,QAAS,2BAA4B,EACjDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAc,IACdC,EAAkB,IA2BtB,SAASC,EAAOC,EAAa,CAC5B,IAAIC,EACJ,GAAKR,EAASO,CAAW,EACxB,OAAAC,EAAID,EAAW,MAAM,EACd,CAAEA,EAAYC,CAAE,EAGxB,GAAKP,EAAkBM,CAAW,EACjC,OAAOF,EAAiBE,CAAW,EAGpC,GACCA,IAAe,MACf,OAAOA,GAAe,UACtB,OAAOA,EAAW,QAAW,UAC7BL,EAAWK,EAAW,MAAO,GAC7BA,EAAW,QAAU,EAErB,OAAOH,EAAaG,CAAW,EAEhC,MAAM,IAAI,UAAWJ,EAAQ,qGAAsGI,CAAW,CAAE,CACjJ,CAKAR,EAAO,QAAUO,ICrCjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_shift_object", "__commonJSMin", "exports", "module", "shift", "obj", "len", "v", "i", "require_shift_typed_array", "__commonJSMin", "exports", "module", "shift", "arr", "offset", "view", "v", "require_main", "__commonJSMin", "exports", "module", "isArray", "isTypedArrayLike", "isInteger", "format", "shiftObject", "shiftTypedArray", "shift", "collection", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e5ceaac..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, number] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, string] - shift( [ true, false ] ); // $ExpectType [Collection, boolean] - shift( [ true, true ] ); // $ExpectType [Collection, boolean] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 9b76edc..d596d8e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..4180de4 --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm,OR', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;qXAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,WAAYlB,GAC1C"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 6300fde..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( '1XXBm,OR', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 59d89ef..f8d4fa1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Remove and return the first element of a collection.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.1.0", - "@stdlib/assert-is-integer": "^0.1.0", - "@stdlib/assert-is-typed-array-like": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.0.6", - "@stdlib/array-float32": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/array-int16": "^0.1.0", - "@stdlib/array-int32": "^0.1.0", - "@stdlib/array-int8": "^0.1.0", - "@stdlib/array-uint16": "^0.1.0", - "@stdlib/array-uint32": "^0.1.0", - "@stdlib/array-uint8": "^0.1.0", - "@stdlib/array-uint8c": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c2427f9 --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From bcb14bc2fb48cf73180d93d45a3457d181f1330e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 17:35:56 +0000 Subject: [PATCH 065/138] 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 7c02fd1..e71d9ba 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import shift from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-shift@esm/index.mjs'; +import shift from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-shift@v0.1.0-esm/index.mjs'; ``` #### shift( collection ) @@ -125,7 +125,7 @@ var lastValue = out[ 1 ]; - - - - From 0df043e8a9f034774a099ed1ada80fa7b3dfdd14 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Oct 2023 12:13:59 +0000 Subject: [PATCH 069/138] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 247 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 9 - dist/index.js.map | 7 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 65 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 206 - test/test.js | 206 - 47 files changed, 6203 insertions(+), 4601 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 48bfd46..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-10-01T02:42:23.835Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 b20300d..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 49ca224..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: '50 14 * * 1' - - # 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 + + ```
@@ -188,7 +181,7 @@ console.log( arr ); ## 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]. @@ -260,11 +253,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index e02c6d1..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b47953c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index 8bb6214..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index 3c8d32e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 63e2f80..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6be7628..0000000 --- a/dist/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var f=u(function(k,s){ -function y(r){var e,i,t;if(r.length===0)return[r,void 0];for(e=r.length-1,i=r[0],t=0;t=0)return T(r);throw new TypeError(E('1XXBm',r))}v.exports=w -});var x=h();module.exports=x; -/** @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 af2e9c8..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/shift_object.js", "../lib/shift_typed_array.js", "../lib/main.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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );\nvar isInteger = require( '@stdlib/assert-is-integer' );\nvar format = require( '@stdlib/string-format' );\nvar shiftObject = require( './shift_object.js' );\nvar shiftTypedArray = require( './shift_typed_array.js' );\n\n\n// MAIN //\n\n/**\n* Removes and returns the first element of a collection.\n*\n* @param {(Array|TypedArray|Object)} collection - collection\n* @throws {TypeError} must provide either an array, typed array, or an array-like object\n* @returns {Array} updated collection and the removed element\n*\n* @example\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Remove and return the first element of a collection.\n*\n* @module @stdlib/utils-shift\n*\n* @example\n* var shift = require( '@stdlib/utils-shift' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,GAAKH,EAAI,SAAW,EACnB,MAAO,CAAEA,EAAK,MAAO,EAMtB,IAJAC,EAAMD,EAAI,OAAS,EACnBE,EAAIF,EAAK,CAAE,EAGLG,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAKG,CAAE,EAAIH,EAAKG,EAAE,CAAE,EAErB,cAAOH,EAAKC,CAAI,EAChBD,EAAI,OAASC,EACN,CAAED,EAAKE,CAAE,CACjB,CAKAJ,EAAO,QAAUC,IC7DjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,OAAKH,EAAI,SAAW,EACZ,CAAEA,EAAK,MAAO,GAEtBG,EAAIH,EAAK,CAAE,EACXC,EAASD,EAAI,WAAaA,EAAI,kBAC9BE,EAAO,IAAIF,EAAI,YAAaA,EAAI,OAAQC,EAAQD,EAAI,OAAO,CAAE,EACtD,CAAEE,EAAMC,CAAE,EAClB,CAKAL,EAAO,QAAUC,ICtDjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,yBAA0B,EAC7CC,EAAmB,QAAS,oCAAqC,EACjEC,EAAY,QAAS,2BAA4B,EACjDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAc,IACdC,EAAkB,IA2BtB,SAASC,EAAOC,EAAa,CAC5B,IAAIC,EACJ,GAAKR,EAASO,CAAW,EACxB,OAAAC,EAAID,EAAW,MAAM,EACd,CAAEA,EAAYC,CAAE,EAGxB,GAAKP,EAAkBM,CAAW,EACjC,OAAOF,EAAiBE,CAAW,EAGpC,GACCA,IAAe,MACf,OAAOA,GAAe,UACtB,OAAOA,EAAW,QAAW,UAC7BL,EAAWK,EAAW,MAAO,GAC7BA,EAAW,QAAU,EAErB,OAAOH,EAAaG,CAAW,EAEhC,MAAM,IAAI,UAAWJ,EAAQ,qGAAsGI,CAAW,CAAE,CACjJ,CAKAR,EAAO,QAAUO,ICrCjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_shift_object", "__commonJSMin", "exports", "module", "shift", "obj", "len", "v", "i", "require_shift_typed_array", "__commonJSMin", "exports", "module", "shift", "arr", "offset", "view", "v", "require_main", "__commonJSMin", "exports", "module", "isArray", "isTypedArrayLike", "isInteger", "format", "shiftObject", "shiftTypedArray", "shift", "collection", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e5ceaac..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, number] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, string] - shift( [ true, false ] ); // $ExpectType [Collection, boolean] - shift( [ true, true ] ); // $ExpectType [Collection, boolean] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 9b76edc..d596d8e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2ea03bf --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm,OR', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,WAAYlB,GAC1C"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 6300fde..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( '1XXBm,OR', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 3da4b9f..f8d4fa1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Remove and return the first element of a collection.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.1.0", - "@stdlib/assert-is-integer": "^0.1.0", - "@stdlib/assert-is-typed-array-like": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.1.0", - "@stdlib/array-float32": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/array-int16": "^0.1.0", - "@stdlib/array-int32": "^0.1.0", - "@stdlib/array-int8": "^0.1.0", - "@stdlib/array-uint16": "^0.1.0", - "@stdlib/array-uint32": "^0.1.0", - "@stdlib/array-uint8": "^0.1.0", - "@stdlib/array-uint8c": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..12eb0d0 --- /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 f6370d9..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From 77dde83319f6a9f7c77aedd805b1971b886f901a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 10:45:28 +0000 Subject: [PATCH 070/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..6300fde 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); @@ -72,7 +72,7 @@ function shift( collection ) { ) { return shiftObject( collection ); } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); + throw new TypeError( format( '1XXBm,OR', collection ) ); } diff --git a/package.json b/package.json index 2221cf7..81f26b0 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.1.1", "@stdlib/assert-is-integer": "^0.1.0", "@stdlib/assert-is-typed-array-like": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.1.0" }, "devDependencies": { From e0b159bb417c0cca392f693cbb3246d0c847d9e8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 6 Oct 2023 14:10:20 +0000 Subject: [PATCH 071/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6239 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 d596d8e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, T]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2ea03bf..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm,OR', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,WAAYlB,GAC1C"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 12eb0d0..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From cad6dcd3c97f7c2e685693e0cf99670e4c79f313 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 6 Oct 2023 14:11:03 +0000 Subject: [PATCH 072/138] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 247 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 9 - dist/index.js.map | 7 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 65 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 206 - test/test.js | 206 - 46 files changed, 6203 insertions(+), 4600 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 b20300d..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 49ca224..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: '50 14 * * 1' - - # 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 + + ```
@@ -188,7 +181,7 @@ console.log( arr ); ## 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]. @@ -260,11 +253,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index e02c6d1..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b47953c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index 8bb6214..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index 3c8d32e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 63e2f80..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6be7628..0000000 --- a/dist/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var f=u(function(k,s){ -function y(r){var e,i,t;if(r.length===0)return[r,void 0];for(e=r.length-1,i=r[0],t=0;t=0)return T(r);throw new TypeError(E('1XXBm',r))}v.exports=w -});var x=h();module.exports=x; -/** @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 af2e9c8..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/shift_object.js", "../lib/shift_typed_array.js", "../lib/main.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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );\nvar isInteger = require( '@stdlib/assert-is-integer' );\nvar format = require( '@stdlib/string-format' );\nvar shiftObject = require( './shift_object.js' );\nvar shiftTypedArray = require( './shift_typed_array.js' );\n\n\n// MAIN //\n\n/**\n* Removes and returns the first element of a collection.\n*\n* @param {(Array|TypedArray|Object)} collection - collection\n* @throws {TypeError} must provide either an array, typed array, or an array-like object\n* @returns {Array} updated collection and the removed element\n*\n* @example\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Remove and return the first element of a collection.\n*\n* @module @stdlib/utils-shift\n*\n* @example\n* var shift = require( '@stdlib/utils-shift' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,GAAKH,EAAI,SAAW,EACnB,MAAO,CAAEA,EAAK,MAAO,EAMtB,IAJAC,EAAMD,EAAI,OAAS,EACnBE,EAAIF,EAAK,CAAE,EAGLG,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAKG,CAAE,EAAIH,EAAKG,EAAE,CAAE,EAErB,cAAOH,EAAKC,CAAI,EAChBD,EAAI,OAASC,EACN,CAAED,EAAKE,CAAE,CACjB,CAKAJ,EAAO,QAAUC,IC7DjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,OAAKH,EAAI,SAAW,EACZ,CAAEA,EAAK,MAAO,GAEtBG,EAAIH,EAAK,CAAE,EACXC,EAASD,EAAI,WAAaA,EAAI,kBAC9BE,EAAO,IAAIF,EAAI,YAAaA,EAAI,OAAQC,EAAQD,EAAI,OAAO,CAAE,EACtD,CAAEE,EAAMC,CAAE,EAClB,CAKAL,EAAO,QAAUC,ICtDjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,yBAA0B,EAC7CC,EAAmB,QAAS,oCAAqC,EACjEC,EAAY,QAAS,2BAA4B,EACjDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAc,IACdC,EAAkB,IA2BtB,SAASC,EAAOC,EAAa,CAC5B,IAAIC,EACJ,GAAKR,EAASO,CAAW,EACxB,OAAAC,EAAID,EAAW,MAAM,EACd,CAAEA,EAAYC,CAAE,EAGxB,GAAKP,EAAkBM,CAAW,EACjC,OAAOF,EAAiBE,CAAW,EAGpC,GACCA,IAAe,MACf,OAAOA,GAAe,UACtB,OAAOA,EAAW,QAAW,UAC7BL,EAAWK,EAAW,MAAO,GAC7BA,EAAW,QAAU,EAErB,OAAOH,EAAaG,CAAW,EAEhC,MAAM,IAAI,UAAWJ,EAAQ,qGAAsGI,CAAW,CAAE,CACjJ,CAKAR,EAAO,QAAUO,ICrCjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_shift_object", "__commonJSMin", "exports", "module", "shift", "obj", "len", "v", "i", "require_shift_typed_array", "__commonJSMin", "exports", "module", "shift", "arr", "offset", "view", "v", "require_main", "__commonJSMin", "exports", "module", "isArray", "isTypedArrayLike", "isInteger", "format", "shiftObject", "shiftTypedArray", "shift", "collection", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e5ceaac..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, number] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, string] - shift( [ true, false ] ); // $ExpectType [Collection, boolean] - shift( [ true, true ] ); // $ExpectType [Collection, boolean] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 9b76edc..d596d8e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f15cfd7 --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm,OR', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,WAAYlB,GAC1C"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 6300fde..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( '1XXBm,OR', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 81f26b0..f8d4fa1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Remove and return the first element of a collection.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-integer": "^0.1.0", - "@stdlib/assert-is-typed-array-like": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.1.0", - "@stdlib/array-float32": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/array-int16": "^0.1.0", - "@stdlib/array-int32": "^0.1.0", - "@stdlib/array-int8": "^0.1.0", - "@stdlib/array-uint16": "^0.1.0", - "@stdlib/array-uint32": "^0.1.0", - "@stdlib/array-uint8": "^0.1.0", - "@stdlib/array-uint8c": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..f4b85d8 --- /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 f6370d9..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From e028a415d6d2998824c125b3aca51a210695147f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 07:46:11 +0000 Subject: [PATCH 073/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..6300fde 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); @@ -72,7 +72,7 @@ function shift( collection ) { ) { return shiftObject( collection ); } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); + throw new TypeError( format( '1XXBm,OR', collection ) ); } diff --git a/package.json b/package.json index 8a098f3..8d6aa60 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.1.1", "@stdlib/assert-is-integer": "^0.1.0", "@stdlib/assert-is-typed-array-like": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.1.0" }, "devDependencies": { From 335d56a6be98cdae2a8b28fbeb1191f2786796fe Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 2 Nov 2023 12:57:38 +0000 Subject: [PATCH 074/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6239 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 d596d8e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, T]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f15cfd7..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm,OR', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,WAAYlB,GAC1C"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f4b85d8..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 81419bbdc8b4a7eade2f220aecaf508c2e74f6c5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 2 Nov 2023 12:58:34 +0000 Subject: [PATCH 075/138] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 9 - dist/index.js.map | 7 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 65 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 206 - 47 files changed, 6203 insertions(+), 4436 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 775f75b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T02:48:01.807Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 b20300d..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 49ca224..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: '50 14 * * 1' - - # 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 + + ```
@@ -188,7 +181,7 @@ console.log( arr ); ## 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]. @@ -260,11 +253,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index e02c6d1..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b47953c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index 8bb6214..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index 3c8d32e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 63e2f80..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6be7628..0000000 --- a/dist/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var f=u(function(k,s){ -function y(r){var e,i,t;if(r.length===0)return[r,void 0];for(e=r.length-1,i=r[0],t=0;t=0)return T(r);throw new TypeError(E('1XXBm',r))}v.exports=w -});var x=h();module.exports=x; -/** @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 af2e9c8..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/shift_object.js", "../lib/shift_typed_array.js", "../lib/main.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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );\nvar isInteger = require( '@stdlib/assert-is-integer' );\nvar format = require( '@stdlib/string-format' );\nvar shiftObject = require( './shift_object.js' );\nvar shiftTypedArray = require( './shift_typed_array.js' );\n\n\n// MAIN //\n\n/**\n* Removes and returns the first element of a collection.\n*\n* @param {(Array|TypedArray|Object)} collection - collection\n* @throws {TypeError} must provide either an array, typed array, or an array-like object\n* @returns {Array} updated collection and the removed element\n*\n* @example\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Remove and return the first element of a collection.\n*\n* @module @stdlib/utils-shift\n*\n* @example\n* var shift = require( '@stdlib/utils-shift' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,GAAKH,EAAI,SAAW,EACnB,MAAO,CAAEA,EAAK,MAAO,EAMtB,IAJAC,EAAMD,EAAI,OAAS,EACnBE,EAAIF,EAAK,CAAE,EAGLG,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAKG,CAAE,EAAIH,EAAKG,EAAE,CAAE,EAErB,cAAOH,EAAKC,CAAI,EAChBD,EAAI,OAASC,EACN,CAAED,EAAKE,CAAE,CACjB,CAKAJ,EAAO,QAAUC,IC7DjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,OAAKH,EAAI,SAAW,EACZ,CAAEA,EAAK,MAAO,GAEtBG,EAAIH,EAAK,CAAE,EACXC,EAASD,EAAI,WAAaA,EAAI,kBAC9BE,EAAO,IAAIF,EAAI,YAAaA,EAAI,OAAQC,EAAQD,EAAI,OAAO,CAAE,EACtD,CAAEE,EAAMC,CAAE,EAClB,CAKAL,EAAO,QAAUC,ICtDjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,yBAA0B,EAC7CC,EAAmB,QAAS,oCAAqC,EACjEC,EAAY,QAAS,2BAA4B,EACjDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAc,IACdC,EAAkB,IA2BtB,SAASC,EAAOC,EAAa,CAC5B,IAAIC,EACJ,GAAKR,EAASO,CAAW,EACxB,OAAAC,EAAID,EAAW,MAAM,EACd,CAAEA,EAAYC,CAAE,EAGxB,GAAKP,EAAkBM,CAAW,EACjC,OAAOF,EAAiBE,CAAW,EAGpC,GACCA,IAAe,MACf,OAAOA,GAAe,UACtB,OAAOA,EAAW,QAAW,UAC7BL,EAAWK,EAAW,MAAO,GAC7BA,EAAW,QAAU,EAErB,OAAOH,EAAaG,CAAW,EAEhC,MAAM,IAAI,UAAWJ,EAAQ,qGAAsGI,CAAW,CAAE,CACjJ,CAKAR,EAAO,QAAUO,ICrCjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_shift_object", "__commonJSMin", "exports", "module", "shift", "obj", "len", "v", "i", "require_shift_typed_array", "__commonJSMin", "exports", "module", "shift", "arr", "offset", "view", "v", "require_main", "__commonJSMin", "exports", "module", "isArray", "isTypedArrayLike", "isInteger", "format", "shiftObject", "shiftTypedArray", "shift", "collection", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e5ceaac..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, number] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, string] - shift( [ true, false ] ); // $ExpectType [Collection, boolean] - shift( [ true, true ] ); // $ExpectType [Collection, boolean] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 9b76edc..d596d8e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f15cfd7 --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm,OR', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,WAAYlB,GAC1C"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 6300fde..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( '1XXBm,OR', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 8d6aa60..f8d4fa1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Remove and return the first element of a collection.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-integer": "^0.1.0", - "@stdlib/assert-is-typed-array-like": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/bench": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..32ce648 --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From 92376fe1dc4995eaf04dc36c1f2323c192a6f0ed Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 06:41:32 +0000 Subject: [PATCH 076/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..6300fde 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); @@ -72,7 +72,7 @@ function shift( collection ) { ) { return shiftObject( collection ); } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); + throw new TypeError( format( '1XXBm,OR', collection ) ); } diff --git a/package.json b/package.json index cf47762..4c6a90a 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.1.1", "@stdlib/assert-is-integer": "^0.1.0", "@stdlib/assert-is-typed-array-like": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From 6faf90ad646253362cfea147fdc64f5e0bc87c69 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 01:35:20 +0000 Subject: [PATCH 077/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6239 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 d596d8e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, T]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f15cfd7..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm,OR', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,WAAYlB,GAC1C"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 32ce648..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From aece4ca30f79ada7a45851e8fe5bcdd537f19fdc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 01:36:07 +0000 Subject: [PATCH 078/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 9 - dist/index.js.map | 7 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 65 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 206 - 47 files changed, 6203 insertions(+), 4431 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index acf2fe9..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T02:58:15.979Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 b20300d..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 49ca224..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: '50 14 * * 1' - - # 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 + + ```
@@ -188,7 +181,7 @@ console.log( arr ); ## 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]. @@ -260,11 +253,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index e02c6d1..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b47953c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index 8bb6214..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index 3c8d32e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 63e2f80..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6be7628..0000000 --- a/dist/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var f=u(function(k,s){ -function y(r){var e,i,t;if(r.length===0)return[r,void 0];for(e=r.length-1,i=r[0],t=0;t=0)return T(r);throw new TypeError(E('1XXBm',r))}v.exports=w -});var x=h();module.exports=x; -/** @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 af2e9c8..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/shift_object.js", "../lib/shift_typed_array.js", "../lib/main.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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );\nvar isInteger = require( '@stdlib/assert-is-integer' );\nvar format = require( '@stdlib/string-format' );\nvar shiftObject = require( './shift_object.js' );\nvar shiftTypedArray = require( './shift_typed_array.js' );\n\n\n// MAIN //\n\n/**\n* Removes and returns the first element of a collection.\n*\n* @param {(Array|TypedArray|Object)} collection - collection\n* @throws {TypeError} must provide either an array, typed array, or an array-like object\n* @returns {Array} updated collection and the removed element\n*\n* @example\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Remove and return the first element of a collection.\n*\n* @module @stdlib/utils-shift\n*\n* @example\n* var shift = require( '@stdlib/utils-shift' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,GAAKH,EAAI,SAAW,EACnB,MAAO,CAAEA,EAAK,MAAO,EAMtB,IAJAC,EAAMD,EAAI,OAAS,EACnBE,EAAIF,EAAK,CAAE,EAGLG,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAKG,CAAE,EAAIH,EAAKG,EAAE,CAAE,EAErB,cAAOH,EAAKC,CAAI,EAChBD,EAAI,OAASC,EACN,CAAED,EAAKE,CAAE,CACjB,CAKAJ,EAAO,QAAUC,IC7DjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,OAAKH,EAAI,SAAW,EACZ,CAAEA,EAAK,MAAO,GAEtBG,EAAIH,EAAK,CAAE,EACXC,EAASD,EAAI,WAAaA,EAAI,kBAC9BE,EAAO,IAAIF,EAAI,YAAaA,EAAI,OAAQC,EAAQD,EAAI,OAAO,CAAE,EACtD,CAAEE,EAAMC,CAAE,EAClB,CAKAL,EAAO,QAAUC,ICtDjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,yBAA0B,EAC7CC,EAAmB,QAAS,oCAAqC,EACjEC,EAAY,QAAS,2BAA4B,EACjDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAc,IACdC,EAAkB,IA2BtB,SAASC,EAAOC,EAAa,CAC5B,IAAIC,EACJ,GAAKR,EAASO,CAAW,EACxB,OAAAC,EAAID,EAAW,MAAM,EACd,CAAEA,EAAYC,CAAE,EAGxB,GAAKP,EAAkBM,CAAW,EACjC,OAAOF,EAAiBE,CAAW,EAGpC,GACCA,IAAe,MACf,OAAOA,GAAe,UACtB,OAAOA,EAAW,QAAW,UAC7BL,EAAWK,EAAW,MAAO,GAC7BA,EAAW,QAAU,EAErB,OAAOH,EAAaG,CAAW,EAEhC,MAAM,IAAI,UAAWJ,EAAQ,qGAAsGI,CAAW,CAAE,CACjJ,CAKAR,EAAO,QAAUO,ICrCjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_shift_object", "__commonJSMin", "exports", "module", "shift", "obj", "len", "v", "i", "require_shift_typed_array", "__commonJSMin", "exports", "module", "shift", "arr", "offset", "view", "v", "require_main", "__commonJSMin", "exports", "module", "isArray", "isTypedArrayLike", "isInteger", "format", "shiftObject", "shiftTypedArray", "shift", "collection", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e5ceaac..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, number] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, string] - shift( [ true, false ] ); // $ExpectType [Collection, boolean] - shift( [ true, true ] ); // $ExpectType [Collection, boolean] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 9b76edc..d596d8e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f15cfd7 --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm,OR', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,WAAYlB,GAC1C"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 6300fde..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( '1XXBm,OR', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 4c6a90a..f8d4fa1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Remove and return the first element of a collection.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-integer": "^0.1.0", - "@stdlib/assert-is-typed-array-like": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/bench": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..aaebcc7 --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From fcf2771d055cc75678d9ed45f40cec6759861510 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 04:12:28 +0000 Subject: [PATCH 079/138] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0c45b09..35d45cc 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.1.1", "@stdlib/assert-is-integer": "^0.1.0", "@stdlib/assert-is-typed-array-like": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From e80d5a40230a70c0a68890c36a8fe05e7e416ff3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 10:18:27 +0000 Subject: [PATCH 080/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6239 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 d596d8e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, T]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f15cfd7..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm,OR', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,WAAYlB,GAC1C"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index aaebcc7..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 7ea11483493184981080afb2fce04748b49fd65b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 10:18:41 +0000 Subject: [PATCH 081/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- SECURITY.md | 5 - benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 9 - dist/index.js.map | 7 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 65 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 206 - 48 files changed, 6203 insertions(+), 4437 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index a2516f0..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T02:34:08.279Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 b20300d..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 49b91e8..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: '50 14 * * 1' - - # 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 + + ```
@@ -188,7 +181,7 @@ console.log( arr ); ## 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]. @@ -260,11 +253,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index d127e5c..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 98434f8..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index b96cd70..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index b141f7e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 63e2f80..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6be7628..0000000 --- a/dist/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var f=u(function(k,s){ -function y(r){var e,i,t;if(r.length===0)return[r,void 0];for(e=r.length-1,i=r[0],t=0;t=0)return T(r);throw new TypeError(E('1XXBm',r))}v.exports=w -});var x=h();module.exports=x; -/** @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 af2e9c8..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/shift_object.js", "../lib/shift_typed_array.js", "../lib/main.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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );\nvar isInteger = require( '@stdlib/assert-is-integer' );\nvar format = require( '@stdlib/string-format' );\nvar shiftObject = require( './shift_object.js' );\nvar shiftTypedArray = require( './shift_typed_array.js' );\n\n\n// MAIN //\n\n/**\n* Removes and returns the first element of a collection.\n*\n* @param {(Array|TypedArray|Object)} collection - collection\n* @throws {TypeError} must provide either an array, typed array, or an array-like object\n* @returns {Array} updated collection and the removed element\n*\n* @example\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Remove and return the first element of a collection.\n*\n* @module @stdlib/utils-shift\n*\n* @example\n* var shift = require( '@stdlib/utils-shift' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,GAAKH,EAAI,SAAW,EACnB,MAAO,CAAEA,EAAK,MAAO,EAMtB,IAJAC,EAAMD,EAAI,OAAS,EACnBE,EAAIF,EAAK,CAAE,EAGLG,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAKG,CAAE,EAAIH,EAAKG,EAAE,CAAE,EAErB,cAAOH,EAAKC,CAAI,EAChBD,EAAI,OAASC,EACN,CAAED,EAAKE,CAAE,CACjB,CAKAJ,EAAO,QAAUC,IC7DjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,OAAKH,EAAI,SAAW,EACZ,CAAEA,EAAK,MAAO,GAEtBG,EAAIH,EAAK,CAAE,EACXC,EAASD,EAAI,WAAaA,EAAI,kBAC9BE,EAAO,IAAIF,EAAI,YAAaA,EAAI,OAAQC,EAAQD,EAAI,OAAO,CAAE,EACtD,CAAEE,EAAMC,CAAE,EAClB,CAKAL,EAAO,QAAUC,ICtDjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,yBAA0B,EAC7CC,EAAmB,QAAS,oCAAqC,EACjEC,EAAY,QAAS,2BAA4B,EACjDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAc,IACdC,EAAkB,IA2BtB,SAASC,EAAOC,EAAa,CAC5B,IAAIC,EACJ,GAAKR,EAASO,CAAW,EACxB,OAAAC,EAAID,EAAW,MAAM,EACd,CAAEA,EAAYC,CAAE,EAGxB,GAAKP,EAAkBM,CAAW,EACjC,OAAOF,EAAiBE,CAAW,EAGpC,GACCA,IAAe,MACf,OAAOA,GAAe,UACtB,OAAOA,EAAW,QAAW,UAC7BL,EAAWK,EAAW,MAAO,GAC7BA,EAAW,QAAU,EAErB,OAAOH,EAAaG,CAAW,EAEhC,MAAM,IAAI,UAAWJ,EAAQ,qGAAsGI,CAAW,CAAE,CACjJ,CAKAR,EAAO,QAAUO,ICrCjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_shift_object", "__commonJSMin", "exports", "module", "shift", "obj", "len", "v", "i", "require_shift_typed_array", "__commonJSMin", "exports", "module", "shift", "arr", "offset", "view", "v", "require_main", "__commonJSMin", "exports", "module", "isArray", "isTypedArrayLike", "isInteger", "format", "shiftObject", "shiftTypedArray", "shift", "collection", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e5ceaac..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, number] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, string] - shift( [ true, false ] ); // $ExpectType [Collection, boolean] - shift( [ true, true ] ); // $ExpectType [Collection, boolean] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 9b76edc..d596d8e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a03a71e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function s(s){var i;if(t(s))return i=s.shift(),[s,i];if(e(s))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(t){var e,r,n;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;mXAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB,GACpI"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 66bb83e..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 35d45cc..f8d4fa1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Remove and return the first element of a collection.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-integer": "^0.1.0", - "@stdlib/assert-is-typed-array-like": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..d06fe35 --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From 27fcb2067d836e33b53546e39d18b7e2a739cb89 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 04:33:40 +0000 Subject: [PATCH 082/138] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0c45b09..35d45cc 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.1.1", "@stdlib/assert-is-integer": "^0.1.0", "@stdlib/assert-is-typed-array-like": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From 0f8387bbdc323ce3bdce7d929834646650e19482 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 09:39:36 +0000 Subject: [PATCH 083/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6239 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 d596d8e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, T]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a03a71e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function s(s){var i;if(t(s))return i=s.shift(),[s,i];if(e(s))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(t){var e,r,n;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;mXAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB,GACpI"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d06fe35..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ac2fa285f8cea46f515e0c9e8ff39519de6372d7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 09:39:57 +0000 Subject: [PATCH 084/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 9 - dist/index.js.map | 7 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 65 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 206 - 48 files changed, 6203 insertions(+), 4442 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index cb4f9dd..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-02-01T03:04:51.057Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 b20300d..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 49b91e8..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: '50 14 * * 1' - - # 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 + + ```
@@ -190,7 +181,7 @@ console.log( arr ); ## 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]. @@ -265,11 +256,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index d127e5c..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 98434f8..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index b96cd70..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index b141f7e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 80517d4..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-shift/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-shift/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6be7628..0000000 --- a/dist/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var f=u(function(k,s){ -function y(r){var e,i,t;if(r.length===0)return[r,void 0];for(e=r.length-1,i=r[0],t=0;t=0)return T(r);throw new TypeError(E('1XXBm',r))}v.exports=w -});var x=h();module.exports=x; -/** @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 af2e9c8..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/shift_object.js", "../lib/shift_typed_array.js", "../lib/main.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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );\nvar isInteger = require( '@stdlib/assert-is-integer' );\nvar format = require( '@stdlib/string-format' );\nvar shiftObject = require( './shift_object.js' );\nvar shiftTypedArray = require( './shift_typed_array.js' );\n\n\n// MAIN //\n\n/**\n* Removes and returns the first element of a collection.\n*\n* @param {(Array|TypedArray|Object)} collection - collection\n* @throws {TypeError} must provide either an array, typed array, or an array-like object\n* @returns {Array} updated collection and the removed element\n*\n* @example\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Remove and return the first element of a collection.\n*\n* @module @stdlib/utils-shift\n*\n* @example\n* var shift = require( '@stdlib/utils-shift' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,GAAKH,EAAI,SAAW,EACnB,MAAO,CAAEA,EAAK,MAAO,EAMtB,IAJAC,EAAMD,EAAI,OAAS,EACnBE,EAAIF,EAAK,CAAE,EAGLG,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAKG,CAAE,EAAIH,EAAKG,EAAE,CAAE,EAErB,cAAOH,EAAKC,CAAI,EAChBD,EAAI,OAASC,EACN,CAAED,EAAKE,CAAE,CACjB,CAKAJ,EAAO,QAAUC,IC7DjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,OAAKH,EAAI,SAAW,EACZ,CAAEA,EAAK,MAAO,GAEtBG,EAAIH,EAAK,CAAE,EACXC,EAASD,EAAI,WAAaA,EAAI,kBAC9BE,EAAO,IAAIF,EAAI,YAAaA,EAAI,OAAQC,EAAQD,EAAI,OAAO,CAAE,EACtD,CAAEE,EAAMC,CAAE,EAClB,CAKAL,EAAO,QAAUC,ICtDjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,yBAA0B,EAC7CC,EAAmB,QAAS,oCAAqC,EACjEC,EAAY,QAAS,2BAA4B,EACjDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAc,IACdC,EAAkB,IA2BtB,SAASC,EAAOC,EAAa,CAC5B,IAAIC,EACJ,GAAKR,EAASO,CAAW,EACxB,OAAAC,EAAID,EAAW,MAAM,EACd,CAAEA,EAAYC,CAAE,EAGxB,GAAKP,EAAkBM,CAAW,EACjC,OAAOF,EAAiBE,CAAW,EAGpC,GACCA,IAAe,MACf,OAAOA,GAAe,UACtB,OAAOA,EAAW,QAAW,UAC7BL,EAAWK,EAAW,MAAO,GAC7BA,EAAW,QAAU,EAErB,OAAOH,EAAaG,CAAW,EAEhC,MAAM,IAAI,UAAWJ,EAAQ,qGAAsGI,CAAW,CAAE,CACjJ,CAKAR,EAAO,QAAUO,ICrCjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_shift_object", "__commonJSMin", "exports", "module", "shift", "obj", "len", "v", "i", "require_shift_typed_array", "__commonJSMin", "exports", "module", "shift", "arr", "offset", "view", "v", "require_main", "__commonJSMin", "exports", "module", "isArray", "isTypedArrayLike", "isInteger", "format", "shiftObject", "shiftTypedArray", "shift", "collection", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e5ceaac..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, number] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, string] - shift( [ true, false ] ); // $ExpectType [Collection, boolean] - shift( [ true, true ] ); // $ExpectType [Collection, boolean] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 6f03d34..4a8b59f 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a03a71e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function s(s){var i;if(t(s))return i=s.shift(),[s,i];if(e(s))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(t){var e,r,n;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;mXAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB,GACpI"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 66bb83e..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 35d45cc..f8d4fa1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Remove and return the first element of a collection.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-integer": "^0.1.0", - "@stdlib/assert-is-typed-array-like": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..e51fc66 --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From 8a261aa5756e4f65cd677299d88b124e0d0e1f95 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 08:24:24 +0000 Subject: [PATCH 085/138] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9fd0bf1..4659dca 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.2.0", "@stdlib/assert-is-integer": "^0.2.0", "@stdlib/assert-is-typed-array-like": "^0.2.0", - "@stdlib/string-format": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.2.0", "@stdlib/types": "^0.3.1" }, "devDependencies": { From 56b9c4eb4bf53d7ea3f1b865e894c0d5a02d3ef1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 16:50:59 +0000 Subject: [PATCH 086/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6239 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 4a8b59f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, T]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a03a71e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function s(s){var i;if(t(s))return i=s.shift(),[s,i];if(e(s))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(t){var e,r,n;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;mXAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB,GACpI"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e51fc66..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 56934eb482282de640ee8491675e96626dee8541 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 16:51:20 +0000 Subject: [PATCH 087/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 9 - dist/index.js.map | 7 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 65 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 206 - 47 files changed, 6203 insertions(+), 4445 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 b20300d..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 8b517b1..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: '50 14 * * 1' - - # 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 + + ```
@@ -190,7 +181,7 @@ console.log( arr ); ## 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]. @@ -265,11 +256,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index d127e5c..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 98434f8..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index b96cd70..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index b141f7e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 80517d4..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-shift/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-shift/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6be7628..0000000 --- a/dist/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var f=u(function(k,s){ -function y(r){var e,i,t;if(r.length===0)return[r,void 0];for(e=r.length-1,i=r[0],t=0;t=0)return T(r);throw new TypeError(E('1XXBm',r))}v.exports=w -});var x=h();module.exports=x; -/** @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 af2e9c8..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/shift_object.js", "../lib/shift_typed_array.js", "../lib/main.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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );\nvar isInteger = require( '@stdlib/assert-is-integer' );\nvar format = require( '@stdlib/string-format' );\nvar shiftObject = require( './shift_object.js' );\nvar shiftTypedArray = require( './shift_typed_array.js' );\n\n\n// MAIN //\n\n/**\n* Removes and returns the first element of a collection.\n*\n* @param {(Array|TypedArray|Object)} collection - collection\n* @throws {TypeError} must provide either an array, typed array, or an array-like object\n* @returns {Array} updated collection and the removed element\n*\n* @example\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Remove and return the first element of a collection.\n*\n* @module @stdlib/utils-shift\n*\n* @example\n* var shift = require( '@stdlib/utils-shift' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,GAAKH,EAAI,SAAW,EACnB,MAAO,CAAEA,EAAK,MAAO,EAMtB,IAJAC,EAAMD,EAAI,OAAS,EACnBE,EAAIF,EAAK,CAAE,EAGLG,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAKG,CAAE,EAAIH,EAAKG,EAAE,CAAE,EAErB,cAAOH,EAAKC,CAAI,EAChBD,EAAI,OAASC,EACN,CAAED,EAAKE,CAAE,CACjB,CAKAJ,EAAO,QAAUC,IC7DjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,OAAKH,EAAI,SAAW,EACZ,CAAEA,EAAK,MAAO,GAEtBG,EAAIH,EAAK,CAAE,EACXC,EAASD,EAAI,WAAaA,EAAI,kBAC9BE,EAAO,IAAIF,EAAI,YAAaA,EAAI,OAAQC,EAAQD,EAAI,OAAO,CAAE,EACtD,CAAEE,EAAMC,CAAE,EAClB,CAKAL,EAAO,QAAUC,ICtDjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,yBAA0B,EAC7CC,EAAmB,QAAS,oCAAqC,EACjEC,EAAY,QAAS,2BAA4B,EACjDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAc,IACdC,EAAkB,IA2BtB,SAASC,EAAOC,EAAa,CAC5B,IAAIC,EACJ,GAAKR,EAASO,CAAW,EACxB,OAAAC,EAAID,EAAW,MAAM,EACd,CAAEA,EAAYC,CAAE,EAGxB,GAAKP,EAAkBM,CAAW,EACjC,OAAOF,EAAiBE,CAAW,EAGpC,GACCA,IAAe,MACf,OAAOA,GAAe,UACtB,OAAOA,EAAW,QAAW,UAC7BL,EAAWK,EAAW,MAAO,GAC7BA,EAAW,QAAU,EAErB,OAAOH,EAAaG,CAAW,EAEhC,MAAM,IAAI,UAAWJ,EAAQ,qGAAsGI,CAAW,CAAE,CACjJ,CAKAR,EAAO,QAAUO,ICrCjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_shift_object", "__commonJSMin", "exports", "module", "shift", "obj", "len", "v", "i", "require_shift_typed_array", "__commonJSMin", "exports", "module", "shift", "arr", "offset", "view", "v", "require_main", "__commonJSMin", "exports", "module", "isArray", "isTypedArrayLike", "isInteger", "format", "shiftObject", "shiftTypedArray", "shift", "collection", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e5ceaac..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, number] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, string] - shift( [ true, false ] ); // $ExpectType [Collection, boolean] - shift( [ true, true ] ); // $ExpectType [Collection, boolean] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 6f03d34..4a8b59f 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a8ef3f9 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function s(s){var i;if(t(s))return i=s.shift(),[s,i];if(e(s))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(s);if(null!==s&&"object"==typeof s&&"number"==typeof s.length&&r(s.length)&&s.length>=0)return function(t){var e,r,n;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],n=0;n[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;mXAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,qGAAsGlB,GACpI"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 66bb83e..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 4659dca..517af5d 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.0", "description": "Remove and return the first element of a collection.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.0", - "@stdlib/assert-is-integer": "^0.2.0", - "@stdlib/assert-is-typed-array-like": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.0", - "@stdlib/types": "^0.3.1" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..dac3f73 --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From b2a73f6a4d2807c96fe77475a031cb6ab1e6f2ec Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 20:06:30 +0000 Subject: [PATCH 088/138] 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 80196f9..02dbe34 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import shift from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-shift@esm/index.mjs'; +import shift from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-shift@v0.2.0-esm/index.mjs'; ``` #### shift( collection ) @@ -125,7 +125,7 @@ var lastValue = out[ 1 ]; - - - - From 519eacb8cfe395f3f592df2c6b66cbb04bc91944 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 24 Feb 2024 17:25:08 +0000 Subject: [PATCH 092/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 -- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 9 - dist/index.js.map | 7 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 65 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 206 - 47 files changed, 4868 insertions(+), 4439 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 b20300d..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 b5ab07c..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: '50 14 * * 1' - - # 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 + + ```
@@ -190,7 +181,7 @@ console.log( arr ); ## 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]. @@ -265,11 +256,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index d127e5c..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 98434f8..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index b96cd70..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index b141f7e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 80517d4..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-shift/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-shift/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6be7628..0000000 --- a/dist/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var f=u(function(k,s){ -function y(r){var e,i,t;if(r.length===0)return[r,void 0];for(e=r.length-1,i=r[0],t=0;t=0)return T(r);throw new TypeError(E('1XXBm',r))}v.exports=w -});var x=h();module.exports=x; -/** @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 af2e9c8..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/shift_object.js", "../lib/shift_typed_array.js", "../lib/main.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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );\nvar isInteger = require( '@stdlib/assert-is-integer' );\nvar format = require( '@stdlib/string-format' );\nvar shiftObject = require( './shift_object.js' );\nvar shiftTypedArray = require( './shift_typed_array.js' );\n\n\n// MAIN //\n\n/**\n* Removes and returns the first element of a collection.\n*\n* @param {(Array|TypedArray|Object)} collection - collection\n* @throws {TypeError} must provide either an array, typed array, or an array-like object\n* @returns {Array} updated collection and the removed element\n*\n* @example\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Remove and return the first element of a collection.\n*\n* @module @stdlib/utils-shift\n*\n* @example\n* var shift = require( '@stdlib/utils-shift' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,GAAKH,EAAI,SAAW,EACnB,MAAO,CAAEA,EAAK,MAAO,EAMtB,IAJAC,EAAMD,EAAI,OAAS,EACnBE,EAAIF,EAAK,CAAE,EAGLG,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAKG,CAAE,EAAIH,EAAKG,EAAE,CAAE,EAErB,cAAOH,EAAKC,CAAI,EAChBD,EAAI,OAASC,EACN,CAAED,EAAKE,CAAE,CACjB,CAKAJ,EAAO,QAAUC,IC7DjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,OAAKH,EAAI,SAAW,EACZ,CAAEA,EAAK,MAAO,GAEtBG,EAAIH,EAAK,CAAE,EACXC,EAASD,EAAI,WAAaA,EAAI,kBAC9BE,EAAO,IAAIF,EAAI,YAAaA,EAAI,OAAQC,EAAQD,EAAI,OAAO,CAAE,EACtD,CAAEE,EAAMC,CAAE,EAClB,CAKAL,EAAO,QAAUC,ICtDjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,yBAA0B,EAC7CC,EAAmB,QAAS,oCAAqC,EACjEC,EAAY,QAAS,2BAA4B,EACjDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAc,IACdC,EAAkB,IA2BtB,SAASC,EAAOC,EAAa,CAC5B,IAAIC,EACJ,GAAKR,EAASO,CAAW,EACxB,OAAAC,EAAID,EAAW,MAAM,EACd,CAAEA,EAAYC,CAAE,EAGxB,GAAKP,EAAkBM,CAAW,EACjC,OAAOF,EAAiBE,CAAW,EAGpC,GACCA,IAAe,MACf,OAAOA,GAAe,UACtB,OAAOA,EAAW,QAAW,UAC7BL,EAAWK,EAAW,MAAO,GAC7BA,EAAW,QAAU,EAErB,OAAOH,EAAaG,CAAW,EAEhC,MAAM,IAAI,UAAWJ,EAAQ,qGAAsGI,CAAW,CAAE,CACjJ,CAKAR,EAAO,QAAUO,ICrCjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_shift_object", "__commonJSMin", "exports", "module", "shift", "obj", "len", "v", "i", "require_shift_typed_array", "__commonJSMin", "exports", "module", "shift", "arr", "offset", "view", "v", "require_main", "__commonJSMin", "exports", "module", "isArray", "isTypedArrayLike", "isInteger", "format", "shiftObject", "shiftTypedArray", "shift", "collection", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e5ceaac..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, number] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, string] - shift( [ true, false ] ); // $ExpectType [Collection, boolean] - shift( [ true, true ] ); // $ExpectType [Collection, boolean] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 6f03d34..4a8b59f 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c85d441 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,QAASlB,GACvC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ffbe815..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( '1XXBm', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 49402d8..9503207 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Remove and return the first element of a collection.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-integer": "^0.2.1", - "@stdlib/assert-is-typed-array-like": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.0", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.0" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..dda24a1 --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From fc479fe0e583dc2a31b31d8a4f629e98e5981b42 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 24 Feb 2024 18:17:53 +0000 Subject: [PATCH 093/138] 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 a51ff2a..4c1b9fc 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import shift from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-shift@esm/index.mjs'; +import shift from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-shift@v0.2.1-esm/index.mjs'; ``` #### shift( collection ) @@ -125,7 +125,7 @@ var lastValue = out[ 1 ]; - - - - From 40987c159e76d3f26cc844b6815b091155f0b271 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 08:08:30 +0000 Subject: [PATCH 097/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 -- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 9 - dist/index.js.map | 7 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 66 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 206 - 48 files changed, 4868 insertions(+), 4442 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 23722a2..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T03:00:46.943Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 b20300d..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 b5ab07c..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: '50 14 * * 1' - - # 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 + + ```
@@ -190,7 +181,7 @@ console.log( arr ); ## 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]. @@ -265,11 +256,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index d127e5c..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 98434f8..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index b96cd70..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index b141f7e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 80517d4..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-shift/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-shift/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6be7628..0000000 --- a/dist/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var f=u(function(k,s){ -function y(r){var e,i,t;if(r.length===0)return[r,void 0];for(e=r.length-1,i=r[0],t=0;t=0)return T(r);throw new TypeError(E('1XXBm',r))}v.exports=w -});var x=h();module.exports=x; -/** @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 af2e9c8..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/shift_object.js", "../lib/shift_typed_array.js", "../lib/main.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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );\nvar isInteger = require( '@stdlib/assert-is-integer' );\nvar format = require( '@stdlib/string-format' );\nvar shiftObject = require( './shift_object.js' );\nvar shiftTypedArray = require( './shift_typed_array.js' );\n\n\n// MAIN //\n\n/**\n* Removes and returns the first element of a collection.\n*\n* @param {(Array|TypedArray|Object)} collection - collection\n* @throws {TypeError} must provide either an array, typed array, or an array-like object\n* @returns {Array} updated collection and the removed element\n*\n* @example\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Remove and return the first element of a collection.\n*\n* @module @stdlib/utils-shift\n*\n* @example\n* var shift = require( '@stdlib/utils-shift' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,GAAKH,EAAI,SAAW,EACnB,MAAO,CAAEA,EAAK,MAAO,EAMtB,IAJAC,EAAMD,EAAI,OAAS,EACnBE,EAAIF,EAAK,CAAE,EAGLG,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAKG,CAAE,EAAIH,EAAKG,EAAE,CAAE,EAErB,cAAOH,EAAKC,CAAI,EAChBD,EAAI,OAASC,EACN,CAAED,EAAKE,CAAE,CACjB,CAKAJ,EAAO,QAAUC,IC7DjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,OAAKH,EAAI,SAAW,EACZ,CAAEA,EAAK,MAAO,GAEtBG,EAAIH,EAAK,CAAE,EACXC,EAASD,EAAI,WAAaA,EAAI,kBAC9BE,EAAO,IAAIF,EAAI,YAAaA,EAAI,OAAQC,EAAQD,EAAI,OAAO,CAAE,EACtD,CAAEE,EAAMC,CAAE,EAClB,CAKAL,EAAO,QAAUC,ICtDjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,yBAA0B,EAC7CC,EAAmB,QAAS,oCAAqC,EACjEC,EAAY,QAAS,2BAA4B,EACjDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAc,IACdC,EAAkB,IA2BtB,SAASC,EAAOC,EAAa,CAC5B,IAAIC,EACJ,GAAKR,EAASO,CAAW,EACxB,OAAAC,EAAID,EAAW,MAAM,EACd,CAAEA,EAAYC,CAAE,EAGxB,GAAKP,EAAkBM,CAAW,EACjC,OAAOF,EAAiBE,CAAW,EAGpC,GACCA,IAAe,MACf,OAAOA,GAAe,UACtB,OAAOA,EAAW,QAAW,UAC7BL,EAAWK,EAAW,MAAO,GAC7BA,EAAW,QAAU,EAErB,OAAOH,EAAaG,CAAW,EAEhC,MAAM,IAAI,UAAWJ,EAAQ,qGAAsGI,CAAW,CAAE,CACjJ,CAKAR,EAAO,QAAUO,ICrCjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_shift_object", "__commonJSMin", "exports", "module", "shift", "obj", "len", "v", "i", "require_shift_typed_array", "__commonJSMin", "exports", "module", "shift", "arr", "offset", "view", "v", "require_main", "__commonJSMin", "exports", "module", "isArray", "isTypedArrayLike", "isInteger", "format", "shiftObject", "shiftTypedArray", "shift", "collection", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e5ceaac..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, number] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, string] - shift( [ true, false ] ); // $ExpectType [Collection, boolean] - shift( [ true, true ] ); // $ExpectType [Collection, boolean] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 6f03d34..4a8b59f 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..04ac9cb --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,QAASlB,GACvC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ffbe815..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( '1XXBm', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index c7ef2bf..9503207 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Remove and return the first element of a collection.", "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,45 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-integer": "^0.2.1", - "@stdlib/assert-is-typed-array-like": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.1", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..4c77d02 --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From 7b947492ff389b5a2732e155e5ef192b992e3bb7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 03:42:08 +0000 Subject: [PATCH 098/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..ffbe815 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); @@ -72,7 +72,7 @@ function shift( collection ) { ) { return shiftObject( collection ); } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); + throw new TypeError( format( '1XXBm', collection ) ); } diff --git a/package.json b/package.json index 0656f3a..c7ef2bf 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.2.1", "@stdlib/assert-is-integer": "^0.2.1", "@stdlib/assert-is-typed-array-like": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, From 8e65a37c8a45c6f26348ec3653dfd85401cb5718 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 07:50:34 +0000 Subject: [PATCH 099/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4904 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 4a8b59f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, T]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 04ac9cb..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,QAASlB,GACvC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4c77d02..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0d2b6102521329b2e2f414842a118187438d8964 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 07:50:43 +0000 Subject: [PATCH 100/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 -- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 9 - dist/index.js.map | 7 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 66 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 206 - 48 files changed, 4868 insertions(+), 4445 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index ce84104..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T02:28:55.069Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 b20300d..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 b5ab07c..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: '50 14 * * 1' - - # 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 + + ```
@@ -190,7 +181,7 @@ console.log( arr ); ## 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]. @@ -265,11 +256,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index d127e5c..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 98434f8..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index b96cd70..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index b141f7e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 80517d4..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-shift/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-shift/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6be7628..0000000 --- a/dist/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var f=u(function(k,s){ -function y(r){var e,i,t;if(r.length===0)return[r,void 0];for(e=r.length-1,i=r[0],t=0;t=0)return T(r);throw new TypeError(E('1XXBm',r))}v.exports=w -});var x=h();module.exports=x; -/** @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 af2e9c8..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/shift_object.js", "../lib/shift_typed_array.js", "../lib/main.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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );\nvar isInteger = require( '@stdlib/assert-is-integer' );\nvar format = require( '@stdlib/string-format' );\nvar shiftObject = require( './shift_object.js' );\nvar shiftTypedArray = require( './shift_typed_array.js' );\n\n\n// MAIN //\n\n/**\n* Removes and returns the first element of a collection.\n*\n* @param {(Array|TypedArray|Object)} collection - collection\n* @throws {TypeError} must provide either an array, typed array, or an array-like object\n* @returns {Array} updated collection and the removed element\n*\n* @example\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Remove and return the first element of a collection.\n*\n* @module @stdlib/utils-shift\n*\n* @example\n* var shift = require( '@stdlib/utils-shift' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,GAAKH,EAAI,SAAW,EACnB,MAAO,CAAEA,EAAK,MAAO,EAMtB,IAJAC,EAAMD,EAAI,OAAS,EACnBE,EAAIF,EAAK,CAAE,EAGLG,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAKG,CAAE,EAAIH,EAAKG,EAAE,CAAE,EAErB,cAAOH,EAAKC,CAAI,EAChBD,EAAI,OAASC,EACN,CAAED,EAAKE,CAAE,CACjB,CAKAJ,EAAO,QAAUC,IC7DjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,OAAKH,EAAI,SAAW,EACZ,CAAEA,EAAK,MAAO,GAEtBG,EAAIH,EAAK,CAAE,EACXC,EAASD,EAAI,WAAaA,EAAI,kBAC9BE,EAAO,IAAIF,EAAI,YAAaA,EAAI,OAAQC,EAAQD,EAAI,OAAO,CAAE,EACtD,CAAEE,EAAMC,CAAE,EAClB,CAKAL,EAAO,QAAUC,ICtDjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,yBAA0B,EAC7CC,EAAmB,QAAS,oCAAqC,EACjEC,EAAY,QAAS,2BAA4B,EACjDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAc,IACdC,EAAkB,IA2BtB,SAASC,EAAOC,EAAa,CAC5B,IAAIC,EACJ,GAAKR,EAASO,CAAW,EACxB,OAAAC,EAAID,EAAW,MAAM,EACd,CAAEA,EAAYC,CAAE,EAGxB,GAAKP,EAAkBM,CAAW,EACjC,OAAOF,EAAiBE,CAAW,EAGpC,GACCA,IAAe,MACf,OAAOA,GAAe,UACtB,OAAOA,EAAW,QAAW,UAC7BL,EAAWK,EAAW,MAAO,GAC7BA,EAAW,QAAU,EAErB,OAAOH,EAAaG,CAAW,EAEhC,MAAM,IAAI,UAAWJ,EAAQ,qGAAsGI,CAAW,CAAE,CACjJ,CAKAR,EAAO,QAAUO,ICrCjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_shift_object", "__commonJSMin", "exports", "module", "shift", "obj", "len", "v", "i", "require_shift_typed_array", "__commonJSMin", "exports", "module", "shift", "arr", "offset", "view", "v", "require_main", "__commonJSMin", "exports", "module", "isArray", "isTypedArrayLike", "isInteger", "format", "shiftObject", "shiftTypedArray", "shift", "collection", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e5ceaac..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, number] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, string] - shift( [ true, false ] ); // $ExpectType [Collection, boolean] - shift( [ true, true ] ); // $ExpectType [Collection, boolean] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 6f03d34..4a8b59f 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..04ac9cb --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,QAASlB,GACvC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ffbe815..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( '1XXBm', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index c7ef2bf..9503207 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Remove and return the first element of a collection.", "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,45 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-integer": "^0.2.1", - "@stdlib/assert-is-typed-array-like": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.1", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..4c77d02 --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From e245c1165e0f94daca9dffa377d35acb3065d131 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 11 Apr 2024 23:51:14 +0000 Subject: [PATCH 101/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..ffbe815 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); @@ -72,7 +72,7 @@ function shift( collection ) { ) { return shiftObject( collection ); } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); + throw new TypeError( format( '1XXBm', collection ) ); } diff --git a/package.json b/package.json index 0656f3a..c7ef2bf 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.2.1", "@stdlib/assert-is-integer": "^0.2.1", "@stdlib/assert-is-typed-array-like": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, From cdc66a31ea6d31e8089e80e9d6fc627d7d8f6623 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 04:43:49 +0000 Subject: [PATCH 102/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4904 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 4a8b59f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, T]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 04ac9cb..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,QAASlB,GACvC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4c77d02..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 7654563496af36694b9b9807ce8b901bc861507a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 04:44:04 +0000 Subject: [PATCH 103/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 134 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 -- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 9 - dist/index.js.map | 7 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 66 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 206 - 47 files changed, 4868 insertions(+), 4446 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 b20300d..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 b5ab07c..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: '50 14 * * 1' - - # 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 + + ```
@@ -190,7 +181,7 @@ console.log( arr ); ## 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]. @@ -265,11 +256,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index d127e5c..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 98434f8..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index b96cd70..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index b141f7e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 80517d4..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-shift/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-shift/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6be7628..0000000 --- a/dist/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var f=u(function(k,s){ -function y(r){var e,i,t;if(r.length===0)return[r,void 0];for(e=r.length-1,i=r[0],t=0;t=0)return T(r);throw new TypeError(E('1XXBm',r))}v.exports=w -});var x=h();module.exports=x; -/** @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 af2e9c8..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/shift_object.js", "../lib/shift_typed_array.js", "../lib/main.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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );\nvar isInteger = require( '@stdlib/assert-is-integer' );\nvar format = require( '@stdlib/string-format' );\nvar shiftObject = require( './shift_object.js' );\nvar shiftTypedArray = require( './shift_typed_array.js' );\n\n\n// MAIN //\n\n/**\n* Removes and returns the first element of a collection.\n*\n* @param {(Array|TypedArray|Object)} collection - collection\n* @throws {TypeError} must provide either an array, typed array, or an array-like object\n* @returns {Array} updated collection and the removed element\n*\n* @example\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Remove and return the first element of a collection.\n*\n* @module @stdlib/utils-shift\n*\n* @example\n* var shift = require( '@stdlib/utils-shift' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,GAAKH,EAAI,SAAW,EACnB,MAAO,CAAEA,EAAK,MAAO,EAMtB,IAJAC,EAAMD,EAAI,OAAS,EACnBE,EAAIF,EAAK,CAAE,EAGLG,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAKG,CAAE,EAAIH,EAAKG,EAAE,CAAE,EAErB,cAAOH,EAAKC,CAAI,EAChBD,EAAI,OAASC,EACN,CAAED,EAAKE,CAAE,CACjB,CAKAJ,EAAO,QAAUC,IC7DjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,OAAKH,EAAI,SAAW,EACZ,CAAEA,EAAK,MAAO,GAEtBG,EAAIH,EAAK,CAAE,EACXC,EAASD,EAAI,WAAaA,EAAI,kBAC9BE,EAAO,IAAIF,EAAI,YAAaA,EAAI,OAAQC,EAAQD,EAAI,OAAO,CAAE,EACtD,CAAEE,EAAMC,CAAE,EAClB,CAKAL,EAAO,QAAUC,ICtDjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,yBAA0B,EAC7CC,EAAmB,QAAS,oCAAqC,EACjEC,EAAY,QAAS,2BAA4B,EACjDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAc,IACdC,EAAkB,IA2BtB,SAASC,EAAOC,EAAa,CAC5B,IAAIC,EACJ,GAAKR,EAASO,CAAW,EACxB,OAAAC,EAAID,EAAW,MAAM,EACd,CAAEA,EAAYC,CAAE,EAGxB,GAAKP,EAAkBM,CAAW,EACjC,OAAOF,EAAiBE,CAAW,EAGpC,GACCA,IAAe,MACf,OAAOA,GAAe,UACtB,OAAOA,EAAW,QAAW,UAC7BL,EAAWK,EAAW,MAAO,GAC7BA,EAAW,QAAU,EAErB,OAAOH,EAAaG,CAAW,EAEhC,MAAM,IAAI,UAAWJ,EAAQ,qGAAsGI,CAAW,CAAE,CACjJ,CAKAR,EAAO,QAAUO,ICrCjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_shift_object", "__commonJSMin", "exports", "module", "shift", "obj", "len", "v", "i", "require_shift_typed_array", "__commonJSMin", "exports", "module", "shift", "arr", "offset", "view", "v", "require_main", "__commonJSMin", "exports", "module", "isArray", "isTypedArrayLike", "isInteger", "format", "shiftObject", "shiftTypedArray", "shift", "collection", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e5ceaac..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, number] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, string] - shift( [ true, false ] ); // $ExpectType [Collection, boolean] - shift( [ true, true ] ); // $ExpectType [Collection, boolean] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 6f03d34..4a8b59f 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..04ac9cb --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,QAASlB,GACvC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ffbe815..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( '1XXBm', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index c7ef2bf..9503207 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Remove and return the first element of a collection.", "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,45 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-integer": "^0.2.1", - "@stdlib/assert-is-typed-array-like": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.1", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..4c77d02 --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From 13cdbc981067716cb9054fad36bbc8913f971522 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 23:36:41 +0000 Subject: [PATCH 104/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..ffbe815 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); @@ -72,7 +72,7 @@ function shift( collection ) { ) { return shiftObject( collection ); } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); + throw new TypeError( format( '1XXBm', collection ) ); } diff --git a/package.json b/package.json index 3d6eaa2..5e36589 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.2.2", "@stdlib/assert-is-integer": "^0.2.2", "@stdlib/assert-is-typed-array-like": "^0.2.1", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From cbeabcf157d9fe30220857eab9c0bdfa2186d285 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 23:41:06 +0000 Subject: [PATCH 105/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4904 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 4a8b59f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, T]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 04ac9cb..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,QAASlB,GACvC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4c77d02..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 28b06870530910344d261ba5390d998e380ab78c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 23:41:28 +0000 Subject: [PATCH 106/138] 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 | 203 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 -- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 9 - dist/index.js.map | 7 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 66 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 206 - 47 files changed, 4868 insertions(+), 4655 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 b20300d..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 b5ab07c..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: '50 14 * * 1' - - # 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 + + ```
@@ -190,7 +181,7 @@ console.log( arr ); ## 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]. @@ -265,11 +256,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index d127e5c..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 98434f8..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index b96cd70..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index b141f7e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 80517d4..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-shift/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-shift/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6be7628..0000000 --- a/dist/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var f=u(function(k,s){ -function y(r){var e,i,t;if(r.length===0)return[r,void 0];for(e=r.length-1,i=r[0],t=0;t=0)return T(r);throw new TypeError(E('1XXBm',r))}v.exports=w -});var x=h();module.exports=x; -/** @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 af2e9c8..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/shift_object.js", "../lib/shift_typed_array.js", "../lib/main.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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );\nvar isInteger = require( '@stdlib/assert-is-integer' );\nvar format = require( '@stdlib/string-format' );\nvar shiftObject = require( './shift_object.js' );\nvar shiftTypedArray = require( './shift_typed_array.js' );\n\n\n// MAIN //\n\n/**\n* Removes and returns the first element of a collection.\n*\n* @param {(Array|TypedArray|Object)} collection - collection\n* @throws {TypeError} must provide either an array, typed array, or an array-like object\n* @returns {Array} updated collection and the removed element\n*\n* @example\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Remove and return the first element of a collection.\n*\n* @module @stdlib/utils-shift\n*\n* @example\n* var shift = require( '@stdlib/utils-shift' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,GAAKH,EAAI,SAAW,EACnB,MAAO,CAAEA,EAAK,MAAO,EAMtB,IAJAC,EAAMD,EAAI,OAAS,EACnBE,EAAIF,EAAK,CAAE,EAGLG,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAKG,CAAE,EAAIH,EAAKG,EAAE,CAAE,EAErB,cAAOH,EAAKC,CAAI,EAChBD,EAAI,OAASC,EACN,CAAED,EAAKE,CAAE,CACjB,CAKAJ,EAAO,QAAUC,IC7DjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,OAAKH,EAAI,SAAW,EACZ,CAAEA,EAAK,MAAO,GAEtBG,EAAIH,EAAK,CAAE,EACXC,EAASD,EAAI,WAAaA,EAAI,kBAC9BE,EAAO,IAAIF,EAAI,YAAaA,EAAI,OAAQC,EAAQD,EAAI,OAAO,CAAE,EACtD,CAAEE,EAAMC,CAAE,EAClB,CAKAL,EAAO,QAAUC,ICtDjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,yBAA0B,EAC7CC,EAAmB,QAAS,oCAAqC,EACjEC,EAAY,QAAS,2BAA4B,EACjDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAc,IACdC,EAAkB,IA2BtB,SAASC,EAAOC,EAAa,CAC5B,IAAIC,EACJ,GAAKR,EAASO,CAAW,EACxB,OAAAC,EAAID,EAAW,MAAM,EACd,CAAEA,EAAYC,CAAE,EAGxB,GAAKP,EAAkBM,CAAW,EACjC,OAAOF,EAAiBE,CAAW,EAGpC,GACCA,IAAe,MACf,OAAOA,GAAe,UACtB,OAAOA,EAAW,QAAW,UAC7BL,EAAWK,EAAW,MAAO,GAC7BA,EAAW,QAAU,EAErB,OAAOH,EAAaG,CAAW,EAEhC,MAAM,IAAI,UAAWJ,EAAQ,qGAAsGI,CAAW,CAAE,CACjJ,CAKAR,EAAO,QAAUO,ICrCjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_shift_object", "__commonJSMin", "exports", "module", "shift", "obj", "len", "v", "i", "require_shift_typed_array", "__commonJSMin", "exports", "module", "shift", "arr", "offset", "view", "v", "require_main", "__commonJSMin", "exports", "module", "isArray", "isTypedArrayLike", "isInteger", "format", "shiftObject", "shiftTypedArray", "shift", "collection", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e5ceaac..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, number] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, string] - shift( [ true, false ] ); // $ExpectType [Collection, boolean] - shift( [ true, true ] ); // $ExpectType [Collection, boolean] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 6f03d34..4a8b59f 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d692e19 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,QAASlB,GACvC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ffbe815..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( '1XXBm', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 5e36589..9d0046a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Remove and return the first element of a collection.", "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,45 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-typed-array-like": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.1", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..1d28c1d --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From 33d868defd8fb7ad5f854a90d962a7c80305fe46 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 23:41:41 +0000 Subject: [PATCH 107/138] 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 1e74e00..1ce289d 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import shift from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-shift@esm/index.mjs'; +import shift from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-shift@v0.2.2-esm/index.mjs'; ``` #### shift( collection ) @@ -125,7 +125,7 @@ var lastValue = out[ 1 ]; - - - - From dcb11ae1da1f4601e1bdbfa48c88384cfa39049f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 08:05:13 +0000 Subject: [PATCH 111/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 158 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 -- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 9 - dist/index.js.map | 7 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 66 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 206 - 48 files changed, 4868 insertions(+), 4613 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 9b6bdc0..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-01T03:02:05.581Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 b20300d..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 b5ab07c..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: '50 14 * * 1' - - # 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 + + ```
@@ -190,7 +181,7 @@ console.log( arr ); ## 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]. @@ -265,11 +256,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index d127e5c..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 98434f8..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index b96cd70..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index b141f7e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 80517d4..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-shift/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-shift/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6be7628..0000000 --- a/dist/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var f=u(function(k,s){ -function y(r){var e,i,t;if(r.length===0)return[r,void 0];for(e=r.length-1,i=r[0],t=0;t=0)return T(r);throw new TypeError(E('1XXBm',r))}v.exports=w -});var x=h();module.exports=x; -/** @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 af2e9c8..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/shift_object.js", "../lib/shift_typed_array.js", "../lib/main.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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );\nvar isInteger = require( '@stdlib/assert-is-integer' );\nvar format = require( '@stdlib/string-format' );\nvar shiftObject = require( './shift_object.js' );\nvar shiftTypedArray = require( './shift_typed_array.js' );\n\n\n// MAIN //\n\n/**\n* Removes and returns the first element of a collection.\n*\n* @param {(Array|TypedArray|Object)} collection - collection\n* @throws {TypeError} must provide either an array, typed array, or an array-like object\n* @returns {Array} updated collection and the removed element\n*\n* @example\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Remove and return the first element of a collection.\n*\n* @module @stdlib/utils-shift\n*\n* @example\n* var shift = require( '@stdlib/utils-shift' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,GAAKH,EAAI,SAAW,EACnB,MAAO,CAAEA,EAAK,MAAO,EAMtB,IAJAC,EAAMD,EAAI,OAAS,EACnBE,EAAIF,EAAK,CAAE,EAGLG,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAKG,CAAE,EAAIH,EAAKG,EAAE,CAAE,EAErB,cAAOH,EAAKC,CAAI,EAChBD,EAAI,OAASC,EACN,CAAED,EAAKE,CAAE,CACjB,CAKAJ,EAAO,QAAUC,IC7DjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,OAAKH,EAAI,SAAW,EACZ,CAAEA,EAAK,MAAO,GAEtBG,EAAIH,EAAK,CAAE,EACXC,EAASD,EAAI,WAAaA,EAAI,kBAC9BE,EAAO,IAAIF,EAAI,YAAaA,EAAI,OAAQC,EAAQD,EAAI,OAAO,CAAE,EACtD,CAAEE,EAAMC,CAAE,EAClB,CAKAL,EAAO,QAAUC,ICtDjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,yBAA0B,EAC7CC,EAAmB,QAAS,oCAAqC,EACjEC,EAAY,QAAS,2BAA4B,EACjDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAc,IACdC,EAAkB,IA2BtB,SAASC,EAAOC,EAAa,CAC5B,IAAIC,EACJ,GAAKR,EAASO,CAAW,EACxB,OAAAC,EAAID,EAAW,MAAM,EACd,CAAEA,EAAYC,CAAE,EAGxB,GAAKP,EAAkBM,CAAW,EACjC,OAAOF,EAAiBE,CAAW,EAGpC,GACCA,IAAe,MACf,OAAOA,GAAe,UACtB,OAAOA,EAAW,QAAW,UAC7BL,EAAWK,EAAW,MAAO,GAC7BA,EAAW,QAAU,EAErB,OAAOH,EAAaG,CAAW,EAEhC,MAAM,IAAI,UAAWJ,EAAQ,qGAAsGI,CAAW,CAAE,CACjJ,CAKAR,EAAO,QAAUO,ICrCjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_shift_object", "__commonJSMin", "exports", "module", "shift", "obj", "len", "v", "i", "require_shift_typed_array", "__commonJSMin", "exports", "module", "shift", "arr", "offset", "view", "v", "require_main", "__commonJSMin", "exports", "module", "isArray", "isTypedArrayLike", "isInteger", "format", "shiftObject", "shiftTypedArray", "shift", "collection", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e5ceaac..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, number] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, string] - shift( [ true, false ] ); // $ExpectType [Collection, boolean] - shift( [ true, true ] ); // $ExpectType [Collection, boolean] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 6f03d34..4a8b59f 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..bf0d72e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,QAASlB,GACvC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ffbe815..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( '1XXBm', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index b257c3e..9d0046a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Remove and return the first element of a collection.", "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,45 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-typed-array-like": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..70cccc6 --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From 33e31dcd509bee64d2b47907d71c9e33cbd16e9e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 19:03:37 +0000 Subject: [PATCH 112/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..ffbe815 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); @@ -72,7 +72,7 @@ function shift( collection ) { ) { return shiftObject( collection ); } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); + throw new TypeError( format( '1XXBm', collection ) ); } diff --git a/package.json b/package.json index aca722b..b257c3e 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.2.2", "@stdlib/assert-is-integer": "^0.2.2", "@stdlib/assert-is-typed-array-like": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 465b25148799cc1352291891fe0a87bfe730874c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 21:56:15 +0000 Subject: [PATCH 113/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4904 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 4a8b59f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, T]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index bf0d72e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,QAASlB,GACvC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 70cccc6..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 82836df3ece35d9940130085ae2ca0c8fe3bc8ac Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 21:56:29 +0000 Subject: [PATCH 114/138] 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 | 203 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 -- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 9 - dist/index.js.map | 7 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 66 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 206 - 48 files changed, 4868 insertions(+), 4658 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 45d99de..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-03T18:07:53.137Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 b20300d..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 b5ab07c..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: '50 14 * * 1' - - # 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 + + ```
@@ -190,7 +181,7 @@ console.log( arr ); ## 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]. @@ -265,11 +256,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index d127e5c..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 98434f8..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index b96cd70..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index b141f7e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 80517d4..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-shift/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-shift/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6be7628..0000000 --- a/dist/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var f=u(function(k,s){ -function y(r){var e,i,t;if(r.length===0)return[r,void 0];for(e=r.length-1,i=r[0],t=0;t=0)return T(r);throw new TypeError(E('1XXBm',r))}v.exports=w -});var x=h();module.exports=x; -/** @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 af2e9c8..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/shift_object.js", "../lib/shift_typed_array.js", "../lib/main.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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );\nvar isInteger = require( '@stdlib/assert-is-integer' );\nvar format = require( '@stdlib/string-format' );\nvar shiftObject = require( './shift_object.js' );\nvar shiftTypedArray = require( './shift_typed_array.js' );\n\n\n// MAIN //\n\n/**\n* Removes and returns the first element of a collection.\n*\n* @param {(Array|TypedArray|Object)} collection - collection\n* @throws {TypeError} must provide either an array, typed array, or an array-like object\n* @returns {Array} updated collection and the removed element\n*\n* @example\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Remove and return the first element of a collection.\n*\n* @module @stdlib/utils-shift\n*\n* @example\n* var shift = require( '@stdlib/utils-shift' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,GAAKH,EAAI,SAAW,EACnB,MAAO,CAAEA,EAAK,MAAO,EAMtB,IAJAC,EAAMD,EAAI,OAAS,EACnBE,EAAIF,EAAK,CAAE,EAGLG,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAKG,CAAE,EAAIH,EAAKG,EAAE,CAAE,EAErB,cAAOH,EAAKC,CAAI,EAChBD,EAAI,OAASC,EACN,CAAED,EAAKE,CAAE,CACjB,CAKAJ,EAAO,QAAUC,IC7DjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,OAAKH,EAAI,SAAW,EACZ,CAAEA,EAAK,MAAO,GAEtBG,EAAIH,EAAK,CAAE,EACXC,EAASD,EAAI,WAAaA,EAAI,kBAC9BE,EAAO,IAAIF,EAAI,YAAaA,EAAI,OAAQC,EAAQD,EAAI,OAAO,CAAE,EACtD,CAAEE,EAAMC,CAAE,EAClB,CAKAL,EAAO,QAAUC,ICtDjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,yBAA0B,EAC7CC,EAAmB,QAAS,oCAAqC,EACjEC,EAAY,QAAS,2BAA4B,EACjDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAc,IACdC,EAAkB,IA2BtB,SAASC,EAAOC,EAAa,CAC5B,IAAIC,EACJ,GAAKR,EAASO,CAAW,EACxB,OAAAC,EAAID,EAAW,MAAM,EACd,CAAEA,EAAYC,CAAE,EAGxB,GAAKP,EAAkBM,CAAW,EACjC,OAAOF,EAAiBE,CAAW,EAGpC,GACCA,IAAe,MACf,OAAOA,GAAe,UACtB,OAAOA,EAAW,QAAW,UAC7BL,EAAWK,EAAW,MAAO,GAC7BA,EAAW,QAAU,EAErB,OAAOH,EAAaG,CAAW,EAEhC,MAAM,IAAI,UAAWJ,EAAQ,qGAAsGI,CAAW,CAAE,CACjJ,CAKAR,EAAO,QAAUO,ICrCjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_shift_object", "__commonJSMin", "exports", "module", "shift", "obj", "len", "v", "i", "require_shift_typed_array", "__commonJSMin", "exports", "module", "shift", "arr", "offset", "view", "v", "require_main", "__commonJSMin", "exports", "module", "isArray", "isTypedArrayLike", "isInteger", "format", "shiftObject", "shiftTypedArray", "shift", "collection", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e5ceaac..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, number] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, string] - shift( [ true, false ] ); // $ExpectType [Collection, boolean] - shift( [ true, true ] ); // $ExpectType [Collection, boolean] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 6f03d34..4a8b59f 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..bf0d72e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,QAASlB,GACvC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ffbe815..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( '1XXBm', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index b257c3e..9d0046a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Remove and return the first element of a collection.", "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,45 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-typed-array-like": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..70cccc6 --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From 68eb90b7c1e5e0e306566cea0cd6cb95ba510d2a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 04:22:17 +0000 Subject: [PATCH 115/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..ffbe815 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); @@ -72,7 +72,7 @@ function shift( collection ) { ) { return shiftObject( collection ); } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); + throw new TypeError( format( '1XXBm', collection ) ); } diff --git a/package.json b/package.json index b33d9ee..471bf1c 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.2.2", "@stdlib/assert-is-integer": "^0.2.2", "@stdlib/assert-is-typed-array-like": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From a6b3e6859bb9c3f1d7ea27903441e53e6eb3cc25 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 07:54:26 +0000 Subject: [PATCH 116/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4904 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 4a8b59f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, T]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index bf0d72e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,QAASlB,GACvC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 70cccc6..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 102b637bfd549cde7feafbe45d152cf4b4bbe59d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 07:54:41 +0000 Subject: [PATCH 117/138] 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 | 203 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 -- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 9 - dist/index.js.map | 7 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 66 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 206 - 48 files changed, 4868 insertions(+), 4658 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 22c876a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-09-01T03:13:28.204Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 b20300d..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 b5ab07c..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: '50 14 * * 1' - - # 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 + + ```
@@ -190,7 +181,7 @@ console.log( arr ); ## 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]. @@ -265,11 +256,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index d127e5c..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 98434f8..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index b96cd70..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index b141f7e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 80517d4..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-shift/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-shift/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6be7628..0000000 --- a/dist/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var f=u(function(k,s){ -function y(r){var e,i,t;if(r.length===0)return[r,void 0];for(e=r.length-1,i=r[0],t=0;t=0)return T(r);throw new TypeError(E('1XXBm',r))}v.exports=w -});var x=h();module.exports=x; -/** @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 af2e9c8..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/shift_object.js", "../lib/shift_typed_array.js", "../lib/main.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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );\nvar isInteger = require( '@stdlib/assert-is-integer' );\nvar format = require( '@stdlib/string-format' );\nvar shiftObject = require( './shift_object.js' );\nvar shiftTypedArray = require( './shift_typed_array.js' );\n\n\n// MAIN //\n\n/**\n* Removes and returns the first element of a collection.\n*\n* @param {(Array|TypedArray|Object)} collection - collection\n* @throws {TypeError} must provide either an array, typed array, or an array-like object\n* @returns {Array} updated collection and the removed element\n*\n* @example\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Remove and return the first element of a collection.\n*\n* @module @stdlib/utils-shift\n*\n* @example\n* var shift = require( '@stdlib/utils-shift' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,GAAKH,EAAI,SAAW,EACnB,MAAO,CAAEA,EAAK,MAAO,EAMtB,IAJAC,EAAMD,EAAI,OAAS,EACnBE,EAAIF,EAAK,CAAE,EAGLG,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAKG,CAAE,EAAIH,EAAKG,EAAE,CAAE,EAErB,cAAOH,EAAKC,CAAI,EAChBD,EAAI,OAASC,EACN,CAAED,EAAKE,CAAE,CACjB,CAKAJ,EAAO,QAAUC,IC7DjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,OAAKH,EAAI,SAAW,EACZ,CAAEA,EAAK,MAAO,GAEtBG,EAAIH,EAAK,CAAE,EACXC,EAASD,EAAI,WAAaA,EAAI,kBAC9BE,EAAO,IAAIF,EAAI,YAAaA,EAAI,OAAQC,EAAQD,EAAI,OAAO,CAAE,EACtD,CAAEE,EAAMC,CAAE,EAClB,CAKAL,EAAO,QAAUC,ICtDjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,yBAA0B,EAC7CC,EAAmB,QAAS,oCAAqC,EACjEC,EAAY,QAAS,2BAA4B,EACjDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAc,IACdC,EAAkB,IA2BtB,SAASC,EAAOC,EAAa,CAC5B,IAAIC,EACJ,GAAKR,EAASO,CAAW,EACxB,OAAAC,EAAID,EAAW,MAAM,EACd,CAAEA,EAAYC,CAAE,EAGxB,GAAKP,EAAkBM,CAAW,EACjC,OAAOF,EAAiBE,CAAW,EAGpC,GACCA,IAAe,MACf,OAAOA,GAAe,UACtB,OAAOA,EAAW,QAAW,UAC7BL,EAAWK,EAAW,MAAO,GAC7BA,EAAW,QAAU,EAErB,OAAOH,EAAaG,CAAW,EAEhC,MAAM,IAAI,UAAWJ,EAAQ,qGAAsGI,CAAW,CAAE,CACjJ,CAKAR,EAAO,QAAUO,ICrCjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_shift_object", "__commonJSMin", "exports", "module", "shift", "obj", "len", "v", "i", "require_shift_typed_array", "__commonJSMin", "exports", "module", "shift", "arr", "offset", "view", "v", "require_main", "__commonJSMin", "exports", "module", "isArray", "isTypedArrayLike", "isInteger", "format", "shiftObject", "shiftTypedArray", "shift", "collection", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e5ceaac..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, number] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, string] - shift( [ true, false ] ); // $ExpectType [Collection, boolean] - shift( [ true, true ] ); // $ExpectType [Collection, boolean] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 6f03d34..4a8b59f 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..bf0d72e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,QAASlB,GACvC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ffbe815..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( '1XXBm', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 471bf1c..9d0046a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Remove and return the first element of a collection.", "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,45 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-typed-array-like": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..70cccc6 --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From bf38ffdfe7075af4107e71594bb5740896e38550 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 04:29:00 +0000 Subject: [PATCH 118/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..ffbe815 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); @@ -72,7 +72,7 @@ function shift( collection ) { ) { return shiftObject( collection ); } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); + throw new TypeError( format( '1XXBm', collection ) ); } diff --git a/package.json b/package.json index b33d9ee..471bf1c 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.2.2", "@stdlib/assert-is-integer": "^0.2.2", "@stdlib/assert-is-typed-array-like": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 55a6a7270677326405648804ea87b6b615285c8f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 08:07:43 +0000 Subject: [PATCH 119/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4904 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 4a8b59f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, T]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index bf0d72e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,QAASlB,GACvC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 70cccc6..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 252f5fed32a83b32168a17433062d4ad133728ff Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 08:07:58 +0000 Subject: [PATCH 120/138] 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 | 203 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 -- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 9 - dist/index.js.map | 7 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 66 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 206 - 48 files changed, 4868 insertions(+), 4658 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 658db95..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-10-01T03:23:02.520Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 b20300d..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 b5ab07c..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: '50 14 * * 1' - - # 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 + + ```
@@ -190,7 +181,7 @@ console.log( arr ); ## 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]. @@ -265,11 +256,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index d127e5c..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 98434f8..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index b96cd70..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index b141f7e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 80517d4..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-shift/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-shift/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6be7628..0000000 --- a/dist/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var f=u(function(k,s){ -function y(r){var e,i,t;if(r.length===0)return[r,void 0];for(e=r.length-1,i=r[0],t=0;t=0)return T(r);throw new TypeError(E('1XXBm',r))}v.exports=w -});var x=h();module.exports=x; -/** @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 af2e9c8..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/shift_object.js", "../lib/shift_typed_array.js", "../lib/main.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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );\nvar isInteger = require( '@stdlib/assert-is-integer' );\nvar format = require( '@stdlib/string-format' );\nvar shiftObject = require( './shift_object.js' );\nvar shiftTypedArray = require( './shift_typed_array.js' );\n\n\n// MAIN //\n\n/**\n* Removes and returns the first element of a collection.\n*\n* @param {(Array|TypedArray|Object)} collection - collection\n* @throws {TypeError} must provide either an array, typed array, or an array-like object\n* @returns {Array} updated collection and the removed element\n*\n* @example\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Remove and return the first element of a collection.\n*\n* @module @stdlib/utils-shift\n*\n* @example\n* var shift = require( '@stdlib/utils-shift' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,GAAKH,EAAI,SAAW,EACnB,MAAO,CAAEA,EAAK,MAAO,EAMtB,IAJAC,EAAMD,EAAI,OAAS,EACnBE,EAAIF,EAAK,CAAE,EAGLG,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAKG,CAAE,EAAIH,EAAKG,EAAE,CAAE,EAErB,cAAOH,EAAKC,CAAI,EAChBD,EAAI,OAASC,EACN,CAAED,EAAKE,CAAE,CACjB,CAKAJ,EAAO,QAAUC,IC7DjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,OAAKH,EAAI,SAAW,EACZ,CAAEA,EAAK,MAAO,GAEtBG,EAAIH,EAAK,CAAE,EACXC,EAASD,EAAI,WAAaA,EAAI,kBAC9BE,EAAO,IAAIF,EAAI,YAAaA,EAAI,OAAQC,EAAQD,EAAI,OAAO,CAAE,EACtD,CAAEE,EAAMC,CAAE,EAClB,CAKAL,EAAO,QAAUC,ICtDjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,yBAA0B,EAC7CC,EAAmB,QAAS,oCAAqC,EACjEC,EAAY,QAAS,2BAA4B,EACjDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAc,IACdC,EAAkB,IA2BtB,SAASC,EAAOC,EAAa,CAC5B,IAAIC,EACJ,GAAKR,EAASO,CAAW,EACxB,OAAAC,EAAID,EAAW,MAAM,EACd,CAAEA,EAAYC,CAAE,EAGxB,GAAKP,EAAkBM,CAAW,EACjC,OAAOF,EAAiBE,CAAW,EAGpC,GACCA,IAAe,MACf,OAAOA,GAAe,UACtB,OAAOA,EAAW,QAAW,UAC7BL,EAAWK,EAAW,MAAO,GAC7BA,EAAW,QAAU,EAErB,OAAOH,EAAaG,CAAW,EAEhC,MAAM,IAAI,UAAWJ,EAAQ,qGAAsGI,CAAW,CAAE,CACjJ,CAKAR,EAAO,QAAUO,ICrCjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_shift_object", "__commonJSMin", "exports", "module", "shift", "obj", "len", "v", "i", "require_shift_typed_array", "__commonJSMin", "exports", "module", "shift", "arr", "offset", "view", "v", "require_main", "__commonJSMin", "exports", "module", "isArray", "isTypedArrayLike", "isInteger", "format", "shiftObject", "shiftTypedArray", "shift", "collection", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e5ceaac..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, number] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, string] - shift( [ true, false ] ); // $ExpectType [Collection, boolean] - shift( [ true, true ] ); // $ExpectType [Collection, boolean] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 6f03d34..4a8b59f 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..bf0d72e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,QAASlB,GACvC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ffbe815..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( '1XXBm', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 471bf1c..9d0046a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Remove and return the first element of a collection.", "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,45 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-typed-array-like": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..70cccc6 --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From f5972ba1d12daf8daedea63ac92343ee51753cb8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 04:26:59 +0000 Subject: [PATCH 121/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..ffbe815 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); @@ -72,7 +72,7 @@ function shift( collection ) { ) { return shiftObject( collection ); } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); + throw new TypeError( format( '1XXBm', collection ) ); } diff --git a/package.json b/package.json index b33d9ee..471bf1c 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.2.2", "@stdlib/assert-is-integer": "^0.2.2", "@stdlib/assert-is-typed-array-like": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 12b4cb9365c00423d5c1e760a3b87dae8c0969b0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 07:40:41 +0000 Subject: [PATCH 122/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4904 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 4a8b59f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, T]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index bf0d72e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,QAASlB,GACvC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 70cccc6..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ce52a6d66f2dbb65438ec679af0029da0fa13f0d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 07:40:58 +0000 Subject: [PATCH 123/138] 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 | 203 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 -- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 9 - dist/index.js.map | 7 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 66 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 206 - 48 files changed, 4868 insertions(+), 4658 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 8ac9947..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-11-01T03:25:12.517Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 b20300d..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 b5ab07c..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: '50 14 * * 1' - - # 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 + + ```
@@ -190,7 +181,7 @@ console.log( arr ); ## 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]. @@ -265,11 +256,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index d127e5c..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 98434f8..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index b96cd70..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index b141f7e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 80517d4..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-shift/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-shift/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6be7628..0000000 --- a/dist/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var f=u(function(k,s){ -function y(r){var e,i,t;if(r.length===0)return[r,void 0];for(e=r.length-1,i=r[0],t=0;t=0)return T(r);throw new TypeError(E('1XXBm',r))}v.exports=w -});var x=h();module.exports=x; -/** @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 af2e9c8..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/shift_object.js", "../lib/shift_typed_array.js", "../lib/main.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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );\nvar isInteger = require( '@stdlib/assert-is-integer' );\nvar format = require( '@stdlib/string-format' );\nvar shiftObject = require( './shift_object.js' );\nvar shiftTypedArray = require( './shift_typed_array.js' );\n\n\n// MAIN //\n\n/**\n* Removes and returns the first element of a collection.\n*\n* @param {(Array|TypedArray|Object)} collection - collection\n* @throws {TypeError} must provide either an array, typed array, or an array-like object\n* @returns {Array} updated collection and the removed element\n*\n* @example\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Remove and return the first element of a collection.\n*\n* @module @stdlib/utils-shift\n*\n* @example\n* var shift = require( '@stdlib/utils-shift' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,GAAKH,EAAI,SAAW,EACnB,MAAO,CAAEA,EAAK,MAAO,EAMtB,IAJAC,EAAMD,EAAI,OAAS,EACnBE,EAAIF,EAAK,CAAE,EAGLG,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAKG,CAAE,EAAIH,EAAKG,EAAE,CAAE,EAErB,cAAOH,EAAKC,CAAI,EAChBD,EAAI,OAASC,EACN,CAAED,EAAKE,CAAE,CACjB,CAKAJ,EAAO,QAAUC,IC7DjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,OAAKH,EAAI,SAAW,EACZ,CAAEA,EAAK,MAAO,GAEtBG,EAAIH,EAAK,CAAE,EACXC,EAASD,EAAI,WAAaA,EAAI,kBAC9BE,EAAO,IAAIF,EAAI,YAAaA,EAAI,OAAQC,EAAQD,EAAI,OAAO,CAAE,EACtD,CAAEE,EAAMC,CAAE,EAClB,CAKAL,EAAO,QAAUC,ICtDjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,yBAA0B,EAC7CC,EAAmB,QAAS,oCAAqC,EACjEC,EAAY,QAAS,2BAA4B,EACjDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAc,IACdC,EAAkB,IA2BtB,SAASC,EAAOC,EAAa,CAC5B,IAAIC,EACJ,GAAKR,EAASO,CAAW,EACxB,OAAAC,EAAID,EAAW,MAAM,EACd,CAAEA,EAAYC,CAAE,EAGxB,GAAKP,EAAkBM,CAAW,EACjC,OAAOF,EAAiBE,CAAW,EAGpC,GACCA,IAAe,MACf,OAAOA,GAAe,UACtB,OAAOA,EAAW,QAAW,UAC7BL,EAAWK,EAAW,MAAO,GAC7BA,EAAW,QAAU,EAErB,OAAOH,EAAaG,CAAW,EAEhC,MAAM,IAAI,UAAWJ,EAAQ,qGAAsGI,CAAW,CAAE,CACjJ,CAKAR,EAAO,QAAUO,ICrCjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_shift_object", "__commonJSMin", "exports", "module", "shift", "obj", "len", "v", "i", "require_shift_typed_array", "__commonJSMin", "exports", "module", "shift", "arr", "offset", "view", "v", "require_main", "__commonJSMin", "exports", "module", "isArray", "isTypedArrayLike", "isInteger", "format", "shiftObject", "shiftTypedArray", "shift", "collection", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e5ceaac..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, number] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, string] - shift( [ true, false ] ); // $ExpectType [Collection, boolean] - shift( [ true, true ] ); // $ExpectType [Collection, boolean] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 6f03d34..4a8b59f 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..bf0d72e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,QAASlB,GACvC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ffbe815..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( '1XXBm', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 471bf1c..9d0046a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Remove and return the first element of a collection.", "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,45 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-typed-array-like": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..70cccc6 --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From 2b0b01360b984332743ff4f4bf1df29832b04673 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 04:40:43 +0000 Subject: [PATCH 124/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..ffbe815 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); @@ -72,7 +72,7 @@ function shift( collection ) { ) { return shiftObject( collection ); } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); + throw new TypeError( format( '1XXBm', collection ) ); } diff --git a/package.json b/package.json index 6d7ad1d..3f6b78c 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.2.2", "@stdlib/assert-is-integer": "^0.2.2", "@stdlib/assert-is-typed-array-like": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From f537a2b50a2762dd6c2938a54f0f2106406515de Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 08:14:00 +0000 Subject: [PATCH 125/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4904 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 4a8b59f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, T]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index bf0d72e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,QAASlB,GACvC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 70cccc6..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 515bf4e0d4e8cd16c6478a18dc3bb0ec4f042267 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 08:14:18 +0000 Subject: [PATCH 126/138] 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 | 203 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 9 - dist/index.js.map | 7 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 66 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 206 - 49 files changed, 4868 insertions(+), 4763 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 602d417..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-01T03:30:08.711Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 b20300d..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 b5ab07c..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: '50 14 * * 1' - - # 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 + + ```
@@ -190,7 +181,7 @@ console.log( arr ); ## 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]. @@ -265,11 +256,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index d127e5c..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 98434f8..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index b96cd70..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index b141f7e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 80517d4..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-shift/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-shift/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6be7628..0000000 --- a/dist/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var f=u(function(k,s){ -function y(r){var e,i,t;if(r.length===0)return[r,void 0];for(e=r.length-1,i=r[0],t=0;t=0)return T(r);throw new TypeError(E('1XXBm',r))}v.exports=w -});var x=h();module.exports=x; -/** @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 af2e9c8..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/shift_object.js", "../lib/shift_typed_array.js", "../lib/main.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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );\nvar isInteger = require( '@stdlib/assert-is-integer' );\nvar format = require( '@stdlib/string-format' );\nvar shiftObject = require( './shift_object.js' );\nvar shiftTypedArray = require( './shift_typed_array.js' );\n\n\n// MAIN //\n\n/**\n* Removes and returns the first element of a collection.\n*\n* @param {(Array|TypedArray|Object)} collection - collection\n* @throws {TypeError} must provide either an array, typed array, or an array-like object\n* @returns {Array} updated collection and the removed element\n*\n* @example\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Remove and return the first element of a collection.\n*\n* @module @stdlib/utils-shift\n*\n* @example\n* var shift = require( '@stdlib/utils-shift' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,GAAKH,EAAI,SAAW,EACnB,MAAO,CAAEA,EAAK,MAAO,EAMtB,IAJAC,EAAMD,EAAI,OAAS,EACnBE,EAAIF,EAAK,CAAE,EAGLG,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAKG,CAAE,EAAIH,EAAKG,EAAE,CAAE,EAErB,cAAOH,EAAKC,CAAI,EAChBD,EAAI,OAASC,EACN,CAAED,EAAKE,CAAE,CACjB,CAKAJ,EAAO,QAAUC,IC7DjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,OAAKH,EAAI,SAAW,EACZ,CAAEA,EAAK,MAAO,GAEtBG,EAAIH,EAAK,CAAE,EACXC,EAASD,EAAI,WAAaA,EAAI,kBAC9BE,EAAO,IAAIF,EAAI,YAAaA,EAAI,OAAQC,EAAQD,EAAI,OAAO,CAAE,EACtD,CAAEE,EAAMC,CAAE,EAClB,CAKAL,EAAO,QAAUC,ICtDjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,yBAA0B,EAC7CC,EAAmB,QAAS,oCAAqC,EACjEC,EAAY,QAAS,2BAA4B,EACjDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAc,IACdC,EAAkB,IA2BtB,SAASC,EAAOC,EAAa,CAC5B,IAAIC,EACJ,GAAKR,EAASO,CAAW,EACxB,OAAAC,EAAID,EAAW,MAAM,EACd,CAAEA,EAAYC,CAAE,EAGxB,GAAKP,EAAkBM,CAAW,EACjC,OAAOF,EAAiBE,CAAW,EAGpC,GACCA,IAAe,MACf,OAAOA,GAAe,UACtB,OAAOA,EAAW,QAAW,UAC7BL,EAAWK,EAAW,MAAO,GAC7BA,EAAW,QAAU,EAErB,OAAOH,EAAaG,CAAW,EAEhC,MAAM,IAAI,UAAWJ,EAAQ,qGAAsGI,CAAW,CAAE,CACjJ,CAKAR,EAAO,QAAUO,ICrCjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_shift_object", "__commonJSMin", "exports", "module", "shift", "obj", "len", "v", "i", "require_shift_typed_array", "__commonJSMin", "exports", "module", "shift", "arr", "offset", "view", "v", "require_main", "__commonJSMin", "exports", "module", "isArray", "isTypedArrayLike", "isInteger", "format", "shiftObject", "shiftTypedArray", "shift", "collection", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e5ceaac..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, number] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, string] - shift( [ true, false ] ); // $ExpectType [Collection, boolean] - shift( [ true, true ] ); // $ExpectType [Collection, boolean] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 6f03d34..4a8b59f 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..bf0d72e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,QAASlB,GACvC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ffbe815..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( '1XXBm', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 3f6b78c..9d0046a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Remove and return the first element of a collection.", "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,45 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-typed-array-like": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..70cccc6 --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From 16b155df39da2542ec3f4db04c95c4431d833f47 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 13 Jan 2025 01:43:18 +0000 Subject: [PATCH 127/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..ffbe815 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); @@ -72,7 +72,7 @@ function shift( collection ) { ) { return shiftObject( collection ); } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); + throw new TypeError( format( '1XXBm', collection ) ); } diff --git a/package.json b/package.json index 6d7ad1d..3f6b78c 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.2.2", "@stdlib/assert-is-integer": "^0.2.2", "@stdlib/assert-is-typed-array-like": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 774177f0257674bb21e16ca320d2afa3467bb0aa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 13 Jan 2025 01:54:53 +0000 Subject: [PATCH 128/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4904 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 4a8b59f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, T]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index bf0d72e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,QAASlB,GACvC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 70cccc6..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0d25107643d72e184b2ca925e15190909266601c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 13 Jan 2025 01:55:09 +0000 Subject: [PATCH 129/138] 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 | 203 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 9 - dist/index.js.map | 7 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 66 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 206 - 49 files changed, 4868 insertions(+), 4763 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0779e8a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 5e79e4f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-01-13T01:41:14.320Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 90926b8..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 b20300d..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 b5ab07c..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: '50 14 * * 1' - - # 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 + + ```
@@ -190,7 +181,7 @@ console.log( arr ); ## 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]. @@ -265,11 +256,11 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index d127e5c..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 98434f8..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index b96cd70..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index b141f7e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 80517d4..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-shift/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-shift/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6be7628..0000000 --- a/dist/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var f=u(function(k,s){ -function y(r){var e,i,t;if(r.length===0)return[r,void 0];for(e=r.length-1,i=r[0],t=0;t=0)return T(r);throw new TypeError(E('1XXBm',r))}v.exports=w -});var x=h();module.exports=x; -/** @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 af2e9c8..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/shift_object.js", "../lib/shift_typed_array.js", "../lib/main.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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );\nvar isInteger = require( '@stdlib/assert-is-integer' );\nvar format = require( '@stdlib/string-format' );\nvar shiftObject = require( './shift_object.js' );\nvar shiftTypedArray = require( './shift_typed_array.js' );\n\n\n// MAIN //\n\n/**\n* Removes and returns the first element of a collection.\n*\n* @param {(Array|TypedArray|Object)} collection - collection\n* @throws {TypeError} must provide either an array, typed array, or an array-like object\n* @returns {Array} updated collection and the removed element\n*\n* @example\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Remove and return the first element of a collection.\n*\n* @module @stdlib/utils-shift\n*\n* @example\n* var shift = require( '@stdlib/utils-shift' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,GAAKH,EAAI,SAAW,EACnB,MAAO,CAAEA,EAAK,MAAO,EAMtB,IAJAC,EAAMD,EAAI,OAAS,EACnBE,EAAIF,EAAK,CAAE,EAGLG,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAKG,CAAE,EAAIH,EAAKG,EAAE,CAAE,EAErB,cAAOH,EAAKC,CAAI,EAChBD,EAAI,OAASC,EACN,CAAED,EAAKE,CAAE,CACjB,CAKAJ,EAAO,QAAUC,IC7DjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,OAAKH,EAAI,SAAW,EACZ,CAAEA,EAAK,MAAO,GAEtBG,EAAIH,EAAK,CAAE,EACXC,EAASD,EAAI,WAAaA,EAAI,kBAC9BE,EAAO,IAAIF,EAAI,YAAaA,EAAI,OAAQC,EAAQD,EAAI,OAAO,CAAE,EACtD,CAAEE,EAAMC,CAAE,EAClB,CAKAL,EAAO,QAAUC,ICtDjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,yBAA0B,EAC7CC,EAAmB,QAAS,oCAAqC,EACjEC,EAAY,QAAS,2BAA4B,EACjDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAc,IACdC,EAAkB,IA2BtB,SAASC,EAAOC,EAAa,CAC5B,IAAIC,EACJ,GAAKR,EAASO,CAAW,EACxB,OAAAC,EAAID,EAAW,MAAM,EACd,CAAEA,EAAYC,CAAE,EAGxB,GAAKP,EAAkBM,CAAW,EACjC,OAAOF,EAAiBE,CAAW,EAGpC,GACCA,IAAe,MACf,OAAOA,GAAe,UACtB,OAAOA,EAAW,QAAW,UAC7BL,EAAWK,EAAW,MAAO,GAC7BA,EAAW,QAAU,EAErB,OAAOH,EAAaG,CAAW,EAEhC,MAAM,IAAI,UAAWJ,EAAQ,qGAAsGI,CAAW,CAAE,CACjJ,CAKAR,EAAO,QAAUO,ICrCjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_shift_object", "__commonJSMin", "exports", "module", "shift", "obj", "len", "v", "i", "require_shift_typed_array", "__commonJSMin", "exports", "module", "shift", "arr", "offset", "view", "v", "require_main", "__commonJSMin", "exports", "module", "isArray", "isTypedArrayLike", "isInteger", "format", "shiftObject", "shiftTypedArray", "shift", "collection", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e5ceaac..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, number] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, string] - shift( [ true, false ] ); // $ExpectType [Collection, boolean] - shift( [ true, true ] ); // $ExpectType [Collection, boolean] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 6f03d34..4a8b59f 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a0e0bfc --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,QAASlB,GACvC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ffbe815..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( '1XXBm', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 3f6b78c..9d0046a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Remove and return the first element of a collection.", "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,45 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-typed-array-like": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..70cccc6 --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From cd76440a5ad555ef66183ff48f9bf7bdac13b026 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 01:50:09 +0000 Subject: [PATCH 130/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..ffbe815 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); @@ -72,7 +72,7 @@ function shift( collection ) { ) { return shiftObject( collection ); } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); + throw new TypeError( format( '1XXBm', collection ) ); } diff --git a/package.json b/package.json index 6d7ad1d..3f6b78c 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.2.2", "@stdlib/assert-is-integer": "^0.2.2", "@stdlib/assert-is-typed-array-like": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 7082ea3241d5068d3cb27f8b520e02e718385126 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 02:23:13 +0000 Subject: [PATCH 131/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4904 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 4a8b59f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, T]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a0e0bfc..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,QAASlB,GACvC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 70cccc6..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 30126b936655d3919889e8cad002d6c1137b9f79 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 02:23:28 +0000 Subject: [PATCH 132/138] 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 | 203 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 9 - dist/index.js.map | 7 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 66 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 206 - 49 files changed, 4868 insertions(+), 4766 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 7a380c6..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-05-26T01:34:14.841Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 37dfbd9..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 b20300d..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 b5ab07c..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: '50 14 * * 1' - - # 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 + + ```
@@ -190,7 +181,7 @@ console.log( arr ); ## 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]. @@ -265,11 +256,11 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index d127e5c..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 98434f8..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index b96cd70..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index b141f7e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 80517d4..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-shift/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-shift/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6be7628..0000000 --- a/dist/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var f=u(function(k,s){ -function y(r){var e,i,t;if(r.length===0)return[r,void 0];for(e=r.length-1,i=r[0],t=0;t=0)return T(r);throw new TypeError(E('1XXBm',r))}v.exports=w -});var x=h();module.exports=x; -/** @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 af2e9c8..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/shift_object.js", "../lib/shift_typed_array.js", "../lib/main.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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );\nvar isInteger = require( '@stdlib/assert-is-integer' );\nvar format = require( '@stdlib/string-format' );\nvar shiftObject = require( './shift_object.js' );\nvar shiftTypedArray = require( './shift_typed_array.js' );\n\n\n// MAIN //\n\n/**\n* Removes and returns the first element of a collection.\n*\n* @param {(Array|TypedArray|Object)} collection - collection\n* @throws {TypeError} must provide either an array, typed array, or an array-like object\n* @returns {Array} updated collection and the removed element\n*\n* @example\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Remove and return the first element of a collection.\n*\n* @module @stdlib/utils-shift\n*\n* @example\n* var shift = require( '@stdlib/utils-shift' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,GAAKH,EAAI,SAAW,EACnB,MAAO,CAAEA,EAAK,MAAO,EAMtB,IAJAC,EAAMD,EAAI,OAAS,EACnBE,EAAIF,EAAK,CAAE,EAGLG,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAKG,CAAE,EAAIH,EAAKG,EAAE,CAAE,EAErB,cAAOH,EAAKC,CAAI,EAChBD,EAAI,OAASC,EACN,CAAED,EAAKE,CAAE,CACjB,CAKAJ,EAAO,QAAUC,IC7DjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,OAAKH,EAAI,SAAW,EACZ,CAAEA,EAAK,MAAO,GAEtBG,EAAIH,EAAK,CAAE,EACXC,EAASD,EAAI,WAAaA,EAAI,kBAC9BE,EAAO,IAAIF,EAAI,YAAaA,EAAI,OAAQC,EAAQD,EAAI,OAAO,CAAE,EACtD,CAAEE,EAAMC,CAAE,EAClB,CAKAL,EAAO,QAAUC,ICtDjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,yBAA0B,EAC7CC,EAAmB,QAAS,oCAAqC,EACjEC,EAAY,QAAS,2BAA4B,EACjDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAc,IACdC,EAAkB,IA2BtB,SAASC,EAAOC,EAAa,CAC5B,IAAIC,EACJ,GAAKR,EAASO,CAAW,EACxB,OAAAC,EAAID,EAAW,MAAM,EACd,CAAEA,EAAYC,CAAE,EAGxB,GAAKP,EAAkBM,CAAW,EACjC,OAAOF,EAAiBE,CAAW,EAGpC,GACCA,IAAe,MACf,OAAOA,GAAe,UACtB,OAAOA,EAAW,QAAW,UAC7BL,EAAWK,EAAW,MAAO,GAC7BA,EAAW,QAAU,EAErB,OAAOH,EAAaG,CAAW,EAEhC,MAAM,IAAI,UAAWJ,EAAQ,qGAAsGI,CAAW,CAAE,CACjJ,CAKAR,EAAO,QAAUO,ICrCjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_shift_object", "__commonJSMin", "exports", "module", "shift", "obj", "len", "v", "i", "require_shift_typed_array", "__commonJSMin", "exports", "module", "shift", "arr", "offset", "view", "v", "require_main", "__commonJSMin", "exports", "module", "isArray", "isTypedArrayLike", "isInteger", "format", "shiftObject", "shiftTypedArray", "shift", "collection", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e5ceaac..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, number] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, string] - shift( [ true, false ] ); // $ExpectType [Collection, boolean] - shift( [ true, true ] ); // $ExpectType [Collection, boolean] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 6f03d34..4a8b59f 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a0e0bfc --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,QAASlB,GACvC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ffbe815..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( '1XXBm', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 3f6b78c..9d0046a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Remove and return the first element of a collection.", "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,45 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-typed-array-like": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..70cccc6 --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From 0a7f94a2a6af59a2b2c0d92009f692328e297b6f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 12 Aug 2025 03:29:58 +0000 Subject: [PATCH 133/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..ffbe815 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); @@ -72,7 +72,7 @@ function shift( collection ) { ) { return shiftObject( collection ); } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); + throw new TypeError( format( '1XXBm', collection ) ); } diff --git a/package.json b/package.json index 6d7ad1d..3f6b78c 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.2.2", "@stdlib/assert-is-integer": "^0.2.2", "@stdlib/assert-is-typed-array-like": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 50e8636049462da1ee231905f4b6e14ddcf80302 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 12 Aug 2025 03:48:42 +0000 Subject: [PATCH 134/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4904 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 4a8b59f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, T]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a0e0bfc..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,QAASlB,GACvC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 70cccc6..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c304922aee664a1e8e236c2e2e1559740eb959d5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 12 Aug 2025 03:49:02 +0000 Subject: [PATCH 135/138] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 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 | 237 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 9 - dist/index.js.map | 7 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 66 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 206 - 48 files changed, 4868 insertions(+), 4799 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 37dfbd9..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 b20300d..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 b5ab07c..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: '50 14 * * 1' - - # 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 + + ```
@@ -190,7 +181,7 @@ console.log( arr ); ## 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]. @@ -265,11 +256,11 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index d127e5c..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 98434f8..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index b96cd70..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index b141f7e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 80517d4..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-shift/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-shift/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6be7628..0000000 --- a/dist/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var f=u(function(k,s){ -function y(r){var e,i,t;if(r.length===0)return[r,void 0];for(e=r.length-1,i=r[0],t=0;t=0)return T(r);throw new TypeError(E('1XXBm',r))}v.exports=w -});var x=h();module.exports=x; -/** @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 af2e9c8..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/shift_object.js", "../lib/shift_typed_array.js", "../lib/main.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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );\nvar isInteger = require( '@stdlib/assert-is-integer' );\nvar format = require( '@stdlib/string-format' );\nvar shiftObject = require( './shift_object.js' );\nvar shiftTypedArray = require( './shift_typed_array.js' );\n\n\n// MAIN //\n\n/**\n* Removes and returns the first element of a collection.\n*\n* @param {(Array|TypedArray|Object)} collection - collection\n* @throws {TypeError} must provide either an array, typed array, or an array-like object\n* @returns {Array} updated collection and the removed element\n*\n* @example\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Remove and return the first element of a collection.\n*\n* @module @stdlib/utils-shift\n*\n* @example\n* var shift = require( '@stdlib/utils-shift' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,GAAKH,EAAI,SAAW,EACnB,MAAO,CAAEA,EAAK,MAAO,EAMtB,IAJAC,EAAMD,EAAI,OAAS,EACnBE,EAAIF,EAAK,CAAE,EAGLG,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAKG,CAAE,EAAIH,EAAKG,EAAE,CAAE,EAErB,cAAOH,EAAKC,CAAI,EAChBD,EAAI,OAASC,EACN,CAAED,EAAKE,CAAE,CACjB,CAKAJ,EAAO,QAAUC,IC7DjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,OAAKH,EAAI,SAAW,EACZ,CAAEA,EAAK,MAAO,GAEtBG,EAAIH,EAAK,CAAE,EACXC,EAASD,EAAI,WAAaA,EAAI,kBAC9BE,EAAO,IAAIF,EAAI,YAAaA,EAAI,OAAQC,EAAQD,EAAI,OAAO,CAAE,EACtD,CAAEE,EAAMC,CAAE,EAClB,CAKAL,EAAO,QAAUC,ICtDjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,yBAA0B,EAC7CC,EAAmB,QAAS,oCAAqC,EACjEC,EAAY,QAAS,2BAA4B,EACjDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAc,IACdC,EAAkB,IA2BtB,SAASC,EAAOC,EAAa,CAC5B,IAAIC,EACJ,GAAKR,EAASO,CAAW,EACxB,OAAAC,EAAID,EAAW,MAAM,EACd,CAAEA,EAAYC,CAAE,EAGxB,GAAKP,EAAkBM,CAAW,EACjC,OAAOF,EAAiBE,CAAW,EAGpC,GACCA,IAAe,MACf,OAAOA,GAAe,UACtB,OAAOA,EAAW,QAAW,UAC7BL,EAAWK,EAAW,MAAO,GAC7BA,EAAW,QAAU,EAErB,OAAOH,EAAaG,CAAW,EAEhC,MAAM,IAAI,UAAWJ,EAAQ,qGAAsGI,CAAW,CAAE,CACjJ,CAKAR,EAAO,QAAUO,ICrCjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_shift_object", "__commonJSMin", "exports", "module", "shift", "obj", "len", "v", "i", "require_shift_typed_array", "__commonJSMin", "exports", "module", "shift", "arr", "offset", "view", "v", "require_main", "__commonJSMin", "exports", "module", "isArray", "isTypedArrayLike", "isInteger", "format", "shiftObject", "shiftTypedArray", "shift", "collection", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e5ceaac..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, number] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, string] - shift( [ true, false ] ); // $ExpectType [Collection, boolean] - shift( [ true, true ] ); // $ExpectType [Collection, boolean] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 6f03d34..4a8b59f 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a0e0bfc --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,QAASlB,GACvC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 51fdcb0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var shift = require( '@stdlib/utils-shift' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ffbe815..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( '1XXBm', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 3f6b78c..9d0046a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Remove and return the first element of a collection.", "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,45 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-typed-array-like": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..70cccc6 --- /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 5380d99..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -}); From 904cac8b0d24e617fa295a588b4f669efcf99e87 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Sep 2025 00:41:44 +0000 Subject: [PATCH 136/138] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 66bb83e..ffbe815 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var isArray = require( '@stdlib/assert-is-array' ); var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); @@ -72,7 +72,7 @@ function shift( collection ) { ) { return shiftObject( collection ); } - throw new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) ); + throw new TypeError( format( '1XXBm', collection ) ); } diff --git a/package.json b/package.json index 6d7ad1d..3f6b78c 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@stdlib/assert-is-array": "^0.2.2", "@stdlib/assert-is-integer": "^0.2.2", "@stdlib/assert-is-typed-array-like": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 7a51323d57a3be02f2a7ee1c379ad8348ac6bada Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Sep 2025 00:46:20 +0000 Subject: [PATCH 137/138] Remove files --- index.d.ts | 57 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4904 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 4a8b59f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Removes and returns the first element of a collection. -* -* ## Notes -* -* - The function returns an array with two elements: the shortened collection and the removed element. -* - If the input collection is a typed array whose length is greater than `0`, the first return value does not equal the input reference. -* - For purposes of generality, always treat the output collection as distinct from the input collection. -* -* @param collection - collection -* @returns updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -declare function shift( collection: Collection ): [Collection, T]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a0e0bfc..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,QAASlB,GACvC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 70cccc6..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From cc1c3bb3cc2c201694b75b33d10be6f4dfb82428 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Sep 2025 00:46:47 +0000 Subject: [PATCH 138/138] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 239 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.control.js | 56 - benchmark/benchmark.js | 82 - benchmark/benchmark.object.js | 89 - benchmark/benchmark.typed_array.js | 271 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 9 - dist/index.js.map | 7 - docs/repl.txt | 44 - docs/types/test.ts | 43 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 81 - lib/shift_object.js | 62 - lib/shift_typed_array.js | 55 - package.json | 66 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 206 - 49 files changed, 4868 insertions(+), 4802 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.control.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.object.js delete mode 100644 benchmark/benchmark.typed_array.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 (95%) 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/shift_object.js delete mode 100644 lib/shift_typed_array.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 8c33033..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-09-01T00:40:48.473Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 37dfbd9..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 b20300d..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 b5ab07c..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: '50 14 * * 1' - - # 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 + + ```
@@ -190,7 +181,7 @@ console.log( arr ); ## 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]. @@ -265,11 +256,11 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop +[@stdlib/utils/pop]: https://github.com/stdlib-js/utils-pop/tree/esm -[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push +[@stdlib/utils/push]: https://github.com/stdlib-js/utils-push/tree/esm -[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift +[@stdlib/utils/unshift]: https://github.com/stdlib-js/utils-unshift/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.control.js b/benchmark/benchmark.control.js deleted file mode 100644 index d127e5c..0000000 --- a/benchmark/benchmark.control.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var pkg = require( './../package.json' ).name; - - -// MAIN // - -bench( pkg+'::float64array,control,constructor', function benchmark( b ) { - var arr; - var buf; - var len; - var i; - - buf = new ArrayBuffer( b.iterations*8 ); // 8 bytes per double - arr = new Float64Array( buf, 0, b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Here, we are only testing the operation of creating a new view each time a value must be removed to a typed array: - len -= 1; - arr = new Float64Array( arr.buffer, arr.byteOffset, len ); - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 98434f8..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in', function benchmark( b ) { - var arr; - var len; - var i; - - len = b.iterations; - arr = new Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.shift(); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.object.js b/benchmark/benchmark.object.js deleted file mode 100644 index b96cd70..0000000 --- a/benchmark/benchmark.object.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::object', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::built-in,object', function benchmark( b ) { - var shift; - var arr; - var len; - var i; - - shift = Array.prototype.shift; - - arr = { - 'length': b.iterations - }; - len = b.iterations; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = i; - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - shift.call( arr ); - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.typed_array.js b/benchmark/benchmark.typed_array.js deleted file mode 100644 index b141f7e..0000000 --- a/benchmark/benchmark.typed_array.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::float64array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float64Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::float32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Float32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint32array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint32Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint16array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint16Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::int8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Int8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8array', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8Array( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::uint8clampedarray', function benchmark( b ) { - var arr; - var len; - var v; - var i; - - arr = new Uint8ClampedArray( b.iterations ); - len = b.iterations; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( arr ); - arr = v[ 0 ]; - len -= 1; - if ( arr.length !== len ) { - b.fail( 'should have removed an element' ); - } - } - b.toc(); - if ( arr.length !== 0 ) { - b.fail( 'should have removed elements' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 80517d4..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift" -%% click B href "https://github.com/stdlib-js/utils-shift/tree/main" -%% click C href "https://github.com/stdlib-js/utils-shift/tree/production" -%% click D href "https://github.com/stdlib-js/utils-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/shift -[production-url]: https://github.com/stdlib-js/utils-shift/tree/production -[deno-url]: https://github.com/stdlib-js/utils-shift/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-shift/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-shift/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-shift/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-shift/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6be7628..0000000 --- a/dist/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var f=u(function(k,s){ -function y(r){var e,i,t;if(r.length===0)return[r,void 0];for(e=r.length-1,i=r[0],t=0;t=0)return T(r);throw new TypeError(E('1XXBm',r))}v.exports=w -});var x=h();module.exports=x; -/** @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 eb4fe0f..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/shift_object.js", "../lib/shift_typed_array.js", "../lib/main.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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );\nvar isInteger = require( '@stdlib/assert-is-integer' );\nvar format = require( '@stdlib/string-format' );\nvar shiftObject = require( './shift_object.js' );\nvar shiftTypedArray = require( './shift_typed_array.js' );\n\n\n// MAIN //\n\n/**\n* Removes and returns the first element of a collection.\n*\n* @param {(Array|TypedArray|Object)} collection - collection\n* @throws {TypeError} must provide either an array, typed array, or an array-like object\n* @returns {Array} updated collection and the removed element\n*\n* @example\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( 'invalid argument. Must provide either an array, typed array, or an array-like object. Value: `%s`.', collection ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Remove and return the first element of a collection.\n*\n* @module @stdlib/utils-shift\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var shift = require( '@stdlib/utils-shift' );\n*\n* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*\n* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,GAAKH,EAAI,SAAW,EACnB,MAAO,CAAEA,EAAK,MAAO,EAMtB,IAJAC,EAAMD,EAAI,OAAS,EACnBE,EAAIF,EAAK,CAAE,EAGLG,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAKG,CAAE,EAAIH,EAAKG,EAAE,CAAE,EAErB,cAAOH,EAAKC,CAAI,EAChBD,EAAI,OAASC,EACN,CAAED,EAAKE,CAAE,CACjB,CAKAJ,EAAO,QAAUC,IC7DjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsCA,SAASC,EAAOC,EAAM,CACrB,IAAIC,EACAC,EACAC,EACJ,OAAKH,EAAI,SAAW,EACZ,CAAEA,EAAK,MAAO,GAEtBG,EAAIH,EAAK,CAAE,EACXC,EAASD,EAAI,WAAaA,EAAI,kBAC9BE,EAAO,IAAIF,EAAI,YAAaA,EAAI,OAAQC,EAAQD,EAAI,OAAO,CAAE,EACtD,CAAEE,EAAMC,CAAE,EAClB,CAKAL,EAAO,QAAUC,ICtDjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,yBAA0B,EAC7CC,EAAmB,QAAS,oCAAqC,EACjEC,EAAY,QAAS,2BAA4B,EACjDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAc,IACdC,EAAkB,IA2BtB,SAASC,EAAOC,EAAa,CAC5B,IAAIC,EACJ,GAAKR,EAASO,CAAW,EACxB,OAAAC,EAAID,EAAW,MAAM,EACd,CAAEA,EAAYC,CAAE,EAGxB,GAAKP,EAAkBM,CAAW,EACjC,OAAOF,EAAiBE,CAAW,EAGpC,GACCA,IAAe,MACf,OAAOA,GAAe,UACtB,OAAOA,EAAW,QAAW,UAC7BL,EAAWK,EAAW,MAAO,GAC7BA,EAAW,QAAU,EAErB,OAAOH,EAAaG,CAAW,EAEhC,MAAM,IAAI,UAAWJ,EAAQ,qGAAsGI,CAAW,CAAE,CACjJ,CAKAR,EAAO,QAAUO,ICrCjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_shift_object", "__commonJSMin", "exports", "module", "shift", "obj", "len", "v", "i", "require_shift_typed_array", "__commonJSMin", "exports", "module", "shift", "arr", "offset", "view", "v", "require_main", "__commonJSMin", "exports", "module", "isArray", "isTypedArrayLike", "isInteger", "format", "shiftObject", "shiftTypedArray", "shift", "collection", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 145f38b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( collection ) - Removes and returns the first element of a collection. - - The function returns an array with two elements: the shortened collection - and the removed element. - - If the input collection is a typed array whose length is greater than `0`, - the first return value does not equal the input reference. - - For purposes of generality, always treat the output collection as distinct - from the input collection. - - Parameters - ---------- - collection: Array|TypedArray|Object - A collection. If the collection is an `Object`, the value should be - array-like. - - Returns - ------- - out: Array - Updated collection and the removed item. - - Examples - -------- - // Arrays: - > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - > var out = {{alias}}( arr ) - [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] - - // Typed arrays: - > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > out = {{alias}}( arr ) - [ [ 2.0 ], 1.0 ] - - // Array-like object: - > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; - > out = {{alias}}( arr ) - [ { 'length': 1, '0': 2.0 }, 1.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index e5ceaac..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import shift = require( './index' ); - - -// TESTS // - -// The function returns the input collection and the removed element... -{ - shift( [ 2, 3 ] ); // $ExpectType [Collection, number] - shift( [ 'a', 'b', 'c' ] ); // $ExpectType [Collection, string] - shift( [ true, false ] ); // $ExpectType [Collection, boolean] - shift( [ true, true ] ); // $ExpectType [Collection, boolean] -} - -// The compiler throws an error if the function is provided a value other than a collection... -{ - shift( true ); // $ExpectError - shift( false ); // $ExpectError - shift( 5 ); // $ExpectError -} - -// The compiler throws an error if the function is not provided one argument... -{ - shift(); // $ExpectError - shift( [ true, true ], 1 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 8ca24be..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( '@stdlib/array-float64' ); -var shift = require( './../lib' ); - -var arr; -var out; -var i; - -arr = new Float64Array( 100 ); -for ( i = 0; i < 100; i++ ) { - out = shift( arr ); - arr = out[ 0 ]; - console.log( 'Length: %d', arr.length ); -} -console.log( arr ); -console.log( 'View Length: %d', arr.byteLength ); -console.log( 'Buffer Length: %d', arr.buffer.byteLength ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 6f03d34..4a8b59f 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a0e0bfc --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array-like@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n){var i;if(t(n))return i=n.shift(),[n,i];if(e(n))return function(t){var e,r;return 0===t.length?[t,void 0]:(r=t[0],e=t.byteOffset+t.BYTES_PER_ELEMENT,[new t.constructor(t.buffer,e,t.length-1),r])}(n);if(null!==n&&"object"==typeof n&&"number"==typeof n.length&&r(n.length)&&n.length>=0)return function(t){var e,r,s;if(0===t.length)return[t,void 0];for(e=t.length-1,r=t[0],s=0;s[ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( collection ) {\n\tvar v;\n\tif ( isArray( collection ) ) {\n\t\tv = collection.shift();\n\t\treturn [ collection, v ];\n\t}\n\t// Check for a typed-array-like object, as verifying actual typed arrays is expensive...\n\tif ( isTypedArrayLike( collection ) ) {\n\t\treturn shiftTypedArray( collection );\n\t}\n\t// Check for an array-like object...\n\tif (\n\t\tcollection !== null &&\n\t\ttypeof collection === 'object' &&\n\t\ttypeof collection.length === 'number' &&\n\t\tisInteger( collection.length ) &&\n\t\tcollection.length >= 0\n\t) {\n\t\treturn shiftObject( collection );\n\t}\n\tthrow new TypeError( format( '1XXBm', collection ) );\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of a typed array.\n*\n* @private\n* @param {TypedArray} arr - input array\n* @returns {Array} input array and the removed element\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* var out = shift( arr );\n* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ]\n*/\nfunction shift( arr ) {\n\tvar offset;\n\tvar view;\n\tvar v;\n\tif ( arr.length === 0 ) {\n\t\treturn [ arr, void 0 ];\n\t}\n\tv = arr[ 0 ];\n\toffset = arr.byteOffset + arr.BYTES_PER_ELEMENT;\n\tview = new arr.constructor( arr.buffer, offset, arr.length-1 );\n\treturn [ view, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Removes and returns the first element of an array-like object.\n*\n* @private\n* @param {Object} obj - input array-like object\n* @returns {Array} input object and the removed element\n*\n* @example\n* var obj = {\n* 'length': 2,\n* '0': 1.0,\n* '1': 2.0\n* };\n*\n* var out = shift( obj );\n* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ]\n*/\nfunction shift( obj ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tif ( obj.length === 0 ) {\n\t\treturn [ obj, void 0 ];\n\t}\n\tlen = obj.length - 1;\n\tv = obj[ 0 ];\n\n\t// Shift all elements down...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tobj[ i ] = obj[ i+1 ];\n\t}\n\tdelete obj[ len ];\n\tobj.length = len;\n\treturn [ obj, v ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","collection","v","isArray","isTypedArrayLike","arr","offset","length","byteOffset","BYTES_PER_ELEMENT","constructor","buffer","shiftTypedArray","isInteger","obj","len","i","shiftObject","TypeError","format"],"mappings":";;4XAsDA,SAASA,EAAOC,GACf,IAAIC,EACJ,GAAKC,EAASF,GAEb,OADAC,EAAID,EAAWD,QACR,CAAEC,EAAYC,GAGtB,GAAKE,EAAkBH,GACtB,OCxBF,SAAgBI,GACf,IAAIC,EAEAJ,EACJ,OAAoB,IAAfG,EAAIE,OACD,CAAEF,OAAK,IAEfH,EAAIG,EAAK,GACTC,EAASD,EAAIG,WAAaH,EAAII,kBAEvB,CADA,IAAIJ,EAAIK,YAAaL,EAAIM,OAAQL,EAAQD,EAAIE,OAAO,GAC5CL,GAChB,CDaSU,CAAiBX,GAGzB,GACgB,OAAfA,GACsB,iBAAfA,GACsB,iBAAtBA,EAAWM,QAClBM,EAAWZ,EAAWM,SACtBN,EAAWM,QAAU,EAErB,OEjCF,SAAgBO,GACf,IAAIC,EACAb,EACAc,EACJ,GAAoB,IAAfF,EAAIP,OACR,MAAO,CAAEO,OAAK,GAMf,IAJAC,EAAMD,EAAIP,OAAS,EACnBL,EAAIY,EAAK,GAGHE,EAAI,EAAGA,EAAID,EAAKC,IACrBF,EAAKE,GAAMF,EAAKE,EAAE,GAInB,cAFOF,EAAKC,GACZD,EAAIP,OAASQ,EACN,CAAED,EAAKZ,EACf,CFgBSe,CAAahB,GAErB,MAAM,IAAIiB,UAAWC,EAAQ,QAASlB,GACvC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f8c465e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove and return the first element of a collection. -* -* @module @stdlib/utils-shift -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var shift = require( '@stdlib/utils-shift' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ffbe815..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert-is-array' ); -var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); -var isInteger = require( '@stdlib/assert-is-integer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var shiftObject = require( './shift_object.js' ); -var shiftTypedArray = require( './shift_typed_array.js' ); - - -// MAIN // - -/** -* Removes and returns the first element of a collection. -* -* @param {(Array|TypedArray|Object)} collection - collection -* @throws {TypeError} must provide either an array, typed array, or an array-like object -* @returns {Array} updated collection and the removed element -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( collection ) { - var v; - if ( isArray( collection ) ) { - v = collection.shift(); - return [ collection, v ]; - } - // Check for a typed-array-like object, as verifying actual typed arrays is expensive... - if ( isTypedArrayLike( collection ) ) { - return shiftTypedArray( collection ); - } - // Check for an array-like object... - if ( - collection !== null && - typeof collection === 'object' && - typeof collection.length === 'number' && - isInteger( collection.length ) && - collection.length >= 0 - ) { - return shiftObject( collection ); - } - throw new TypeError( format( '1XXBm', collection ) ); -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_object.js b/lib/shift_object.js deleted file mode 100644 index 866aa6a..0000000 --- a/lib/shift_object.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Removes and returns the first element of an array-like object. -* -* @private -* @param {Object} obj - input array-like object -* @returns {Array} input object and the removed element -* -* @example -* var obj = { -* 'length': 2, -* '0': 1.0, -* '1': 2.0 -* }; -* -* var out = shift( obj ); -* // returns [ { 'length': 1, '0': 2.0 }, 1.0 ] -*/ -function shift( obj ) { - var len; - var v; - var i; - if ( obj.length === 0 ) { - return [ obj, void 0 ]; - } - len = obj.length - 1; - v = obj[ 0 ]; - - // Shift all elements down... - for ( i = 0; i < len; i++ ) { - obj[ i ] = obj[ i+1 ]; - } - delete obj[ len ]; - obj.length = len; - return [ obj, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/lib/shift_typed_array.js b/lib/shift_typed_array.js deleted file mode 100644 index 87d408f..0000000 --- a/lib/shift_typed_array.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 // - -/** -* Removes and returns the first element of a typed array. -* -* @private -* @param {TypedArray} arr - input array -* @returns {Array} input array and the removed element -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* -* var out = shift( arr ); -* // returns [ [ 2.0, 3.0, 4.0, 5.0 ], 1.0 ] -*/ -function shift( arr ) { - var offset; - var view; - var v; - if ( arr.length === 0 ) { - return [ arr, void 0 ]; - } - v = arr[ 0 ]; - offset = arr.byteOffset + arr.BYTES_PER_ELEMENT; - view = new arr.constructor( arr.buffer, offset, arr.length-1 ); - return [ view, v ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 3f6b78c..9d0046a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Remove and return the first element of a collection.", "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,45 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-integer": "^0.2.2", - "@stdlib/assert-is-typed-array-like": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..70cccc6 --- /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 4c57931..0000000 --- a/test/test.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert-is-array' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided either an array, typed array, or an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - function noop() {}, - new Date(), - new RegExp( '.+' ), // eslint-disable-line prefer-regex-literals - {}, - { 'length': null }, - { 'length': -1 }, - { 'length': 3.14 } - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - shift( value ); - }; - } -}); - -tape( 'the function returns a two-element array', function test( t ) { - var out; - var arr; - - arr = [ 1.0, 2.0, 3.0 ]; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - - t.end(); -}); - -tape( 'if provided an empty collection, the element value is `undefined`', function test( t ) { - var out; - var arr; - - arr = []; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = new Float32Array(); - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - arr = { - 'length': 0 - }; - out = shift( arr ); - t.strictEqual( isArray( out ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'output array has length 2' ); - t.strictEqual( out[ 1 ], void 0, 'element is `undefined`' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input array' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of an array-like object', function test( t ) { - var arr; - var out; - - arr = { - 'length': 3, - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'returns input collection' ); - t.strictEqual( out[ 1 ], 1.0, 'returns first value' ); - t.strictEqual( arr[ 2 ], void 0, 'removes last value' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 1.0, 'returns the first element' ); - - t.end(); -}); - -tape( 'the function removes and returns the first element of a typed array (offset view)', function test( t ) { - var arr; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - arr = new Float64Array( buf, 2*8, 2 ); // 8 bytes per double - - arr[ 0 ] = 3.0; - arr[ 1 ] = 4.0; - - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 3.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.notEqual( out[ 0 ], arr, 'does not return input array (new view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], 4.0, 'returns first element' ); - - arr = out[ 0 ]; - out = shift( arr ); - - t.strictEqual( out[ 0 ], arr, 'return input array (same view)' ); - t.strictEqual( out[ 0 ].buffer, arr.buffer, 'same underlying buffer' ); - t.strictEqual( out[ 1 ], void 0, 'returns `undefined`' ); - - t.end(); -});